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
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace MongoDB\Tests;
use MongoDB\Model\CollectionInfo;
use MongoDB\Tests\TestCase;
class CollectionInfoTest extends TestCase
{
public function testGetName()
{
$info = new CollectionInfo(['name' => 'foo']);
$this->assertSame('foo', $info->getName());
}
public function testGetOptions()
{
$info = new CollectionInfo(['name' => 'foo']);
$this->assertSame([], $info->getOptions());
$info = new CollectionInfo(['name' => 'foo', 'options' => ['capped' => true, 'size' => 1048576]]);
$this->assertSame(['capped' => true, 'size' => 1048576], $info->getOptions());
}
public function testCappedCollectionMethods()
{
$info = new CollectionInfo(['name' => 'foo']);
$this->assertFalse($info->isCapped());
$this->assertNull($info->getCappedMax());
$this->assertNull($info->getCappedSize());
$info = new CollectionInfo(['name' => 'foo', 'options' => ['capped' => true, 'size' => 1048576]]);
$this->assertTrue($info->isCapped());
$this->assertNull($info->getCappedMax());
$this->assertSame(1048576, $info->getCappedSize());
$info = new CollectionInfo(['name' => 'foo', 'options' => ['capped' => true, 'size' => 1048576, 'max' => 100]]);
$this->assertTrue($info->isCapped());
$this->assertSame(100, $info->getCappedMax());
$this->assertSame(1048576, $info->getCappedSize());
}
public function testDebugInfo()
{
$expectedInfo = [
'name' => 'foo',
'options' => ['capped' => true, 'size' => 1048576],
];
$info = new CollectionInfo($expectedInfo);
$this->assertSame($expectedInfo, $info->__debugInfo());
}
}