本文整理汇总了PHP中PHPUnit_Util_Blacklist::isBlacklisted方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Blacklist::isBlacklisted方法的具体用法?PHP PHPUnit_Util_Blacklist::isBlacklisted怎么用?PHP PHPUnit_Util_Blacklist::isBlacklisted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_Blacklist
的用法示例。
在下文中一共展示了PHPUnit_Util_Blacklist::isBlacklisted方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilteredStacktrace
/**
* Filters stack frames from PHPUnit classes.
*
* @param Exception $e
* @param bool $asString
* @return string
*/
public static function getFilteredStacktrace(Exception $e, $asString = true)
{
$prefix = false;
$script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
if (defined('__PHPUNIT_PHAR_ROOT__')) {
$prefix = __PHPUNIT_PHAR_ROOT__;
}
if ($asString === true) {
$filteredStacktrace = '';
} else {
$filteredStacktrace = array();
}
if ($e instanceof PHPUnit_Framework_SyntheticError) {
$eTrace = $e->getSyntheticTrace();
$eFile = $e->getSyntheticFile();
$eLine = $e->getSyntheticLine();
} elseif ($e instanceof PHPUnit_Framework_Exception) {
$eTrace = $e->getSerializableTrace();
$eFile = $e->getFile();
$eLine = $e->getLine();
} else {
if ($e->getPrevious()) {
$e = $e->getPrevious();
}
$eTrace = $e->getTrace();
$eFile = $e->getFile();
$eLine = $e->getLine();
}
if (!self::frameExists($eTrace, $eFile, $eLine)) {
array_unshift($eTrace, array('file' => $eFile, 'line' => $eLine));
}
$blacklist = new PHPUnit_Util_Blacklist();
foreach ($eTrace as $frame) {
if (isset($frame['file']) && is_file($frame['file']) && !$blacklist->isBlacklisted($frame['file']) && ($prefix === false || strpos($frame['file'], $prefix) !== 0) && $frame['file'] !== $script) {
if ($asString === true) {
$filteredStacktrace .= sprintf("%s:%s\n", $frame['file'], isset($frame['line']) ? $frame['line'] : '?');
} else {
$filteredStacktrace[] = $frame;
}
}
}
return $filteredStacktrace;
}
示例2: processIncludedFilesAsString
public static function processIncludedFilesAsString(array $files)
{
$blacklist = new PHPUnit_Util_Blacklist();
$prefix = false;
$result = '';
if (defined('__PHPUNIT_PHAR__')) {
$prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
}
for ($i = count($files) - 1; $i > 0; $i--) {
$file = $files[$i];
if ($prefix !== false && strpos($file, $prefix) === 0) {
continue;
}
// Skip virtual file system protocols
if (preg_match('/^(vfs|phpvfs[a-z0-9]+):/', $file)) {
continue;
}
if (!$blacklist->isBlacklisted($file) && is_file($file)) {
$result = 'require_once \'' . $file . "';\n" . $result;
}
}
return $result;
}
示例3: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
*/
public function run(PHPUnit_Framework_Test $test)
{
PHPUnit_Framework_Assert::resetCount();
$error = false;
$failure = false;
$warning = false;
$incomplete = false;
$risky = false;
$skipped = false;
$this->startTest($test);
$errorHandlerSet = false;
if ($this->convertErrorsToExceptions) {
$oldErrorHandler = set_error_handler(['PHPUnit_Util_ErrorHandler', 'handleError'], E_ALL | E_STRICT);
if ($oldErrorHandler === null) {
$errorHandlerSet = true;
} else {
restore_error_handler();
}
}
$collectCodeCoverage = $this->codeCoverage !== null && !$test instanceof PHPUnit_Framework_WarningTestCase;
if ($collectCodeCoverage) {
$this->codeCoverage->start($test);
}
$monitorFunctions = $this->beStrictAboutResourceUsageDuringSmallTests && !$test instanceof PHPUnit_Framework_WarningTestCase && $test->getSize() == PHPUnit_Util_Test::SMALL && function_exists('xdebug_start_function_monitor');
if ($monitorFunctions) {
xdebug_start_function_monitor(ResourceOperations::getFunctions());
}
PHP_Timer::start();
try {
if (!$test instanceof PHPUnit_Framework_WarningTestCase && $test->getSize() != PHPUnit_Util_Test::UNKNOWN && $this->enforceTimeLimit && extension_loaded('pcntl') && class_exists('PHP_Invoker')) {
switch ($test->getSize()) {
case PHPUnit_Util_Test::SMALL:
$_timeout = $this->timeoutForSmallTests;
break;
case PHPUnit_Util_Test::MEDIUM:
$_timeout = $this->timeoutForMediumTests;
break;
case PHPUnit_Util_Test::LARGE:
$_timeout = $this->timeoutForLargeTests;
break;
}
$invoker = new PHP_Invoker();
$invoker->invoke([$test, 'runBare'], [], $_timeout);
} else {
$test->runBare();
}
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = true;
if ($e instanceof PHPUnit_Framework_RiskyTestError) {
$risky = true;
} elseif ($e instanceof PHPUnit_Framework_IncompleteTestError) {
$incomplete = true;
} elseif ($e instanceof PHPUnit_Framework_SkippedTestError) {
$skipped = true;
}
} catch (PHPUnit_Framework_Warning $e) {
$warning = true;
} catch (PHPUnit_Framework_Exception $e) {
$error = true;
} catch (Throwable $e) {
$e = new PHPUnit_Framework_ExceptionWrapper($e);
$error = true;
} catch (Exception $e) {
$e = new PHPUnit_Framework_ExceptionWrapper($e);
$error = true;
}
$time = PHP_Timer::stop();
$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
if ($monitorFunctions) {
$blacklist = new PHPUnit_Util_Blacklist();
$functions = xdebug_get_monitored_functions();
xdebug_stop_function_monitor();
foreach ($functions as $function) {
if (!$blacklist->isBlacklisted($function['filename'])) {
$this->addFailure($test, new PHPUnit_Framework_RiskyTestError(sprintf('%s() used in %s:%s', $function['function'], $function['filename'], $function['lineno'])), $time);
}
}
}
if ($this->beStrictAboutTestsThatDoNotTestAnything && $test->getNumAssertions() == 0) {
$risky = true;
}
if ($collectCodeCoverage) {
$append = !$risky && !$incomplete && !$skipped;
$linesToBeCovered = [];
$linesToBeUsed = [];
if ($append && $test instanceof PHPUnit_Framework_TestCase) {
$linesToBeCovered = PHPUnit_Util_Test::getLinesToBeCovered(get_class($test), $test->getName(false));
$linesToBeUsed = PHPUnit_Util_Test::getLinesToBeUsed(get_class($test), $test->getName(false));
}
try {
$this->codeCoverage->stop($append, $linesToBeCovered, $linesToBeUsed);
} catch (PHP_CodeCoverage_UnintentionallyCoveredCodeException $cce) {
$this->addFailure($test, new PHPUnit_Framework_UnintentionallyCoveredCodeError('This test executed code that is not listed as code to be covered or used:' . PHP_EOL . $cce->getMessage()), $time);
} catch (PHPUnit_Framework_InvalidCoversTargetException $cce) {
$this->addFailure($test, new PHPUnit_Framework_InvalidCoversTargetError($cce->getMessage()), $time);
//.........这里部分代码省略.........
示例4: getIncludedFilesAsString
public static function getIncludedFilesAsString()
{
$blacklist = new PHPUnit_Util_Blacklist();
$files = get_included_files();
$prefix = false;
$result = '';
if (defined('__PHPUNIT_PHAR__')) {
$prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
}
for ($i = count($files) - 1; $i > 0; $i--) {
$file = $files[$i];
if ($prefix !== false && strpos($file, $prefix) === 0) {
continue;
}
if (!$blacklist->isBlacklisted($file) && is_file($file)) {
$result = 'require_once \'' . $file . "';\n" . $result;
}
}
return $result;
}
示例5: getDependendClasses
/**
* Get the dependend classes of this test.
*
* @return string[] An array containing class names as keys and path to the
* file's defining class as value.
*
* @author Dominik del Bondio <dominik.del.bondio@bitextender.com>
* @since 1.1.0
*/
private function getDependendClasses()
{
// We need to collect the dependend classes in case there is a test which
// has set @agaviBootstrap to off. That results in the Agavi autoloader not
// being started and if the test class depends on any files from Agavi (like
// AgaviPhpUnitTestCase) it would not be loaded when the test is instantiated
$classesInTest = array();
$reflectionClass = new ReflectionClass(get_class($this));
$testFile = $reflectionClass->getFileName();
$getDeclaredFuncs = array('get_declared_classes', 'get_declared_interfaces');
if (version_compare(PHP_VERSION, '5.4', '>=')) {
$getDeclaredFuncs[] = 'get_declared_traits';
}
foreach ($getDeclaredFuncs as $getDeclaredFunc) {
foreach ($getDeclaredFunc() as $name) {
$reflectionClass = new ReflectionClass($name);
if ($testFile === $reflectionClass->getFileName()) {
$classesInTest[] = $name;
}
}
}
// FIXME: added by phpunit 4.x
if (class_exists('PHPUnit_Util_Blacklist')) {
$blacklist = new PHPUnit_Util_Blacklist();
$isBlacklisted = function ($file) use($testFile, $blacklist) {
return $file === $testFile || $blacklist->isBlacklisted($file);
};
} elseif (is_callable(array('PHPUnit_Util_GlobalState', 'phpunitFiles'))) {
$blacklist = PHPUnit_Util_GlobalState::phpunitFiles();
$isBlacklisted = function ($file) use($testFile, $blacklist) {
return $file === $testFile || isset($blacklist[$file]);
};
} else {
$isBlacklisted = function ($file) use($testFile) {
return $file === $testFile;
};
}
$classesToFile = array('AgaviTesting' => realpath(__DIR__ . '/AgaviTesting.class.php'));
foreach ($classesInTest as $className) {
$classesToFile = array_merge($classesToFile, $this->getClassDependendFiles(new ReflectionClass($className), $isBlacklisted));
}
return $classesToFile;
}