| Server IP : 54.233.248.239 / Your IP : 172.28.1.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/vinumday2_0/vendor/mongodb/mongodb/tests/Model/ |
Upload File : |
<?php
namespace MongoDB\Tests;
use MongoDB\Model\IndexInfo;
use MongoDB\Tests\TestCase;
class IndexInfoTest extends TestCase
{
public function testBasicIndex()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['x' => 1],
'name' => 'x_1',
'ns' => 'foo.bar',
]);
$this->assertSame(1, $info->getVersion());
$this->assertSame(['x' => 1], $info->getKey());
$this->assertSame('x_1', $info->getName());
$this->assertSame('foo.bar', $info->getNamespace());
$this->assertFalse($info->isSparse());
$this->assertFalse($info->isTtl());
$this->assertFalse($info->isUnique());
}
public function testSparseIndex()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['y' => 1],
'name' => 'y_sparse',
'ns' => 'foo.bar',
'sparse' => true,
]);
$this->assertSame(1, $info->getVersion());
$this->assertSame(['y' => 1], $info->getKey());
$this->assertSame('y_sparse', $info->getName());
$this->assertSame('foo.bar', $info->getNamespace());
$this->assertTrue($info->isSparse());
$this->assertFalse($info->isTtl());
$this->assertFalse($info->isUnique());
}
public function testUniqueIndex()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['z' => 1],
'name' => 'z_unique',
'ns' => 'foo.bar',
'unique' => true,
]);
$this->assertSame(1, $info->getVersion());
$this->assertSame(['z' => 1], $info->getKey());
$this->assertSame('z_unique', $info->getName());
$this->assertSame('foo.bar', $info->getNamespace());
$this->assertFalse($info->isSparse());
$this->assertFalse($info->isTtl());
$this->assertTrue($info->isUnique());
}
public function testTtlIndex()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['z' => 1],
'name' => 'z_unique',
'ns' => 'foo.bar',
'expireAfterSeconds' => 100,
]);
$this->assertSame(1, $info->getVersion());
$this->assertSame(['z' => 1], $info->getKey());
$this->assertSame('z_unique', $info->getName());
$this->assertSame('foo.bar', $info->getNamespace());
$this->assertFalse($info->isSparse());
$this->assertTrue($info->isTtl());
$this->assertFalse($info->isUnique());
$this->assertTrue(isset($info['expireAfterSeconds']));
$this->assertSame(100, $info['expireAfterSeconds']);
}
public function testDebugInfo()
{
$expectedInfo = [
'v' => 1,
'key' => ['x' => 1],
'name' => 'x_1',
'ns' => 'foo.bar',
];
$info = new IndexInfo($expectedInfo);
$this->assertSame($expectedInfo, $info->__debugInfo());
}
public function testImplementsArrayAccess()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['x' => 1],
'name' => 'x_1',
'ns' => 'foo.bar',
]);
$this->assertInstanceOf('ArrayAccess', $info);
$this->assertTrue(isset($info['name']));
$this->assertSame('x_1', $info['name']);
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\IndexInfo is immutable
*/
public function testOffsetSetCannotBeCalled()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['x' => 1],
'name' => 'x_1',
'ns' => 'foo.bar',
]);
$info['v'] = 2;
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\IndexInfo is immutable
*/
public function testOffsetUnsetCannotBeCalled()
{
$info = new IndexInfo([
'v' => 1,
'key' => ['x' => 1],
'name' => 'x_1',
'ns' => 'foo.bar',
]);
unset($info['v']);
}
}