本文整理汇总了PHP中CacheUtil::readCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheUtil::readCache方法的具体用法?PHP CacheUtil::readCache怎么用?PHP CacheUtil::readCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheUtil
的用法示例。
在下文中一共展示了CacheUtil::readCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateAndReadCache
public function testCreateAndReadCache()
{
$cache = new CacheUtil();
$test1 = new RerunRandomTest();
$test2 = new RerunRandomTest();
$failedTestsToWrite = array(array('testMethodName' => $test1->getName(), 'testClassName' => get_class($test1)), array('testMethodName' => $test2->getName(), 'testClassName' => get_class($test2)));
$cmdOptions = array('phpunit', 'testName');
$cache->createCache($failedTestsToWrite, $cmdOptions);
$key = $cache->generateKey($cmdOptions);
$failedTestsFromFile = $cache->readCache($key);
$this->assertEquals($failedTestsToWrite, $failedTestsFromFile, 'Test written to file differ from those read from file');
}
示例2: doRun
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
{
$this->handleConfiguration($arguments);
$this->processSuiteFilters($suite, $arguments);
// -----------------------
// get the tests that failed last time this same command (without rerun) was used
// from file and rerun them
if (isset($arguments['rerun'])) {
$cache = new CacheUtil();
$key = $cache->generateKey($_SERVER['argv']);
if ($cache->fileExists($key)) {
$rerunnableTests = $cache->readCache($key);
$suite = new PHPUnit_Framework_TestSuite();
foreach ($rerunnableTests as $testName) {
$class = new ReflectionClass($testName['testClassName']);
$methodName = $testName['testMethodName'];
$test = $suite::createTest($class, $methodName);
$suite->addTest($test);
}
}
}
// ------------------------------
if (isset($arguments['bootstrap'])) {
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
}
if ($arguments['backupGlobals'] === false) {
$suite->setBackupGlobals(false);
}
if ($arguments['backupStaticAttributes'] === true) {
$suite->setBackupStaticAttributes(true);
}
if ($arguments['disallowChangesToGlobalState'] === true) {
$suite->setDisallowChangesToGlobalState(true);
}
if (is_integer($arguments['repeat'])) {
$test = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['processIsolation']);
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTest($test);
}
$result = $this->createTestResult();
if (!$arguments['convertErrorsToExceptions']) {
$result->convertErrorsToExceptions(false);
}
if (!$arguments['convertNoticesToExceptions']) {
PHPUnit_Framework_Error_Notice::$enabled = false;
}
if (!$arguments['convertWarningsToExceptions']) {
PHPUnit_Framework_Error_Warning::$enabled = false;
}
if ($arguments['stopOnError']) {
$result->stopOnError(true);
}
if ($arguments['stopOnFailure']) {
$result->stopOnFailure(true);
}
if ($arguments['stopOnIncomplete']) {
$result->stopOnIncomplete(true);
}
if ($arguments['stopOnRisky']) {
$result->stopOnRisky(true);
}
if ($arguments['stopOnSkipped']) {
$result->stopOnSkipped(true);
}
if ($this->printer === null) {
if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
$this->printer = $arguments['printer'];
} else {
$printerClass = 'PHPUnit_TextUI_ResultPrinter';
if (isset($arguments['printer']) && is_string($arguments['printer']) && class_exists($arguments['printer'], false)) {
$class = new ReflectionClass($arguments['printer']);
if ($class->isSubclassOf('PHPUnit_TextUI_ResultPrinter')) {
$printerClass = $arguments['printer'];
}
}
$this->printer = new $printerClass(isset($arguments['stderr']) ? 'php://stderr' : null, $arguments['verbose'], $arguments['colors'], $arguments['debug'], $arguments['columns']);
}
}
if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
$this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n");
self::$versionStringPrinted = true;
if ($arguments['verbose']) {
$this->printer->write(sprintf("\nRuntime:\t%s", $this->runtime->getNameWithVersion()));
if ($this->runtime->hasXdebug()) {
$this->printer->write(sprintf(' with Xdebug %s', phpversion('xdebug')));
}
if (isset($arguments['configuration'])) {
$this->printer->write(sprintf("\nConfiguration:\t%s", $arguments['configuration']->getFilename()));
}
$this->printer->write("\n");
}
if (isset($arguments['deprecatedStrictModeOption'])) {
print "Warning:\tDeprecated option \"--strict\" used\n";
} elseif (isset($arguments['deprecatedStrictModeSetting'])) {
print "Warning:\tDeprecated configuration setting \"strict\" used\n";
}
if (isset($arguments['deprecatedSeleniumConfiguration'])) {
print "Warning:\tDeprecated configuration setting \"selenium\" used\n";
}
}
//.........这里部分代码省略.........