-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathMongoGridFSCursorTest.php
40 lines (33 loc) · 1.25 KB
/
MongoGridFSCursorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Alcaeus\MongoDbAdapter\Tests\Mongo;
use Alcaeus\MongoDbAdapter\Tests\TestCase;
class MongoGridFSCursorTest extends TestCase
{
public function testSerialize()
{
$gridfs = $this->getGridFS();
$gridfs->storeBytes('foo', ['filename' => 'foo.txt']);
$gridfs->storeBytes('bar', ['filename' => 'bar.txt']);
$cursor = $gridfs->find(['filename' => 'foo.txt']);
$this->assertInternalType('string', serialize($cursor));
}
public function testCursorItems()
{
$gridfs = $this->getGridFS();
$id = $gridfs->storeBytes('foo', ['filename' => 'foo.txt']);
$gridfs->storeBytes('bar', ['filename' => 'bar.txt']);
$cursor = $gridfs->find(['filename' => 'foo.txt']);
$this->assertCount(1, $cursor);
foreach ($cursor as $key => $value) {
$this->assertSame((string)$id, $key);
$this->assertInstanceOf('MongoGridFSFile', $value);
$this->assertSame('foo', $value->getBytes());
$this->assertArraySubset([
'filename' => 'foo.txt',
'chunkSize' => 261120,
'length' => 3,
'md5' => 'acbd18db4cc2f85cedef654fccc4a4d8'
], $value->file);
}
}
}