MongoGridFSCursorTest.php 887 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Alcaeus\MongoDbAdapter\Tests;
  3. class MongoGridFSCursorTest extends TestCase
  4. {
  5. public function testCursorItems()
  6. {
  7. $gridfs = $this->getGridFS();
  8. $id = $gridfs->storeBytes('foo', ['filename' => 'foo.txt']);
  9. $gridfs->storeBytes('bar', ['filename' => 'bar.txt']);
  10. $cursor = $gridfs->find(['filename' => 'foo.txt']);
  11. $this->assertCount(1, $cursor);
  12. foreach ($cursor as $key => $value) {
  13. $this->assertSame((string)$id, $key);
  14. $this->assertInstanceOf('MongoGridFSFile', $value);
  15. $this->assertSame('foo', $value->getBytes());
  16. $this->assertArraySubset([
  17. 'filename' => 'foo.txt',
  18. 'chunkSize' => 261120,
  19. 'length' => 3,
  20. 'md5' => 'acbd18db4cc2f85cedef654fccc4a4d8'
  21. ], $value->file);
  22. }
  23. }
  24. }