| Server IP : 54.94.228.101 / Your IP : 172.28.20.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/ |
Upload File : |
<?php
namespace MongoDB\Tests;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use ReflectionClass;
use stdClass;
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
public function provideInvalidDocumentValues()
{
return $this->wrapValuesForDataProvider($this->getInvalidDocumentValues());
}
/**
* 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 a list of invalid array values.
*
* @return array
*/
protected function getInvalidArrayValues()
{
return [123, 3.14, 'foo', true, new stdClass];
}
/**
* Return a list of invalid boolean values.
*
* @return array
*/
protected function getInvalidBooleanValues()
{
return [123, 3.14, 'foo', [], new stdClass];
}
/**
* Return a list of invalid document values.
*
* @return array
*/
protected function getInvalidDocumentValues()
{
return [123, 3.14, 'foo', true];
}
/**
* Return a list of invalid integer values.
*
* @return array
*/
protected function getInvalidIntegerValues()
{
return [3.14, 'foo', true, [], new stdClass];
}
/**
* Return a list of invalid ReadPreference values.
*
* @return array
*/
protected function getInvalidReadConcernValues()
{
return [123, 3.14, 'foo', true, [], new stdClass, new ReadPreference(ReadPreference::RP_PRIMARY), new WriteConcern(1)];
}
/**
* Return a list of invalid ReadPreference values.
*
* @return array
*/
protected function getInvalidReadPreferenceValues()
{
return [123, 3.14, 'foo', true, [], new stdClass, new ReadConcern, new WriteConcern(1)];
}
/**
* Return a list of invalid string values.
*
* @return array
*/
protected function getInvalidStringValues()
{
return [123, 3.14, true, [], new stdClass];
}
/**
* Return a list of invalid WriteConcern values.
*
* @return array
*/
protected function getInvalidWriteConcernValues()
{
return [123, 3.14, 'foo', true, [], new stdClass, new ReadConcern, new ReadPreference(ReadPreference::RP_PRIMARY)];
}
/**
* 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';
}
/**
* Wrap a list of values for use as a single-argument data provider.
*
* @param array $values List of values
* @return array
*/
protected function wrapValuesForDataProvider(array $values)
{
return array_map(function($value) { return [$value]; }, $values);
}
}