MongoGridFSCursorTest.php 937 B

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