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
<?php
namespace MongoDB\Tests;
use ReflectionClass;
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* Return the test collection name.
*
* @return string
*/
protected function getCollectionName()
{
$class = new ReflectionClass($this);
return sprintf('%s.%s', $class->getShortName(), hash('crc32b', $this->getName()));
}
/**
* Return the test database name.
*
* @return string
*/
protected function getDatabaseName()
{
return getenv('MONGODB_DATABASE') ?: 'phplib_test';
}
/**
* Return the test namespace.
*
* @return string
*/
protected function getNamespace()
{
return sprintf('%s.%s', $this->getDatabaseName(), $this->getCollectionName());
}
/**
* Return the connection URI.
*
* @return string
*/
protected function getUri()
{
return getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1:27017';
}
}