本文整理匯總了PHP中PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist方法的典型用法代碼示例。如果您正苦於以下問題:PHP PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist方法的具體用法?PHP PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist怎麽用?PHP PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHP_CodeCoverage
的用法示例。
在下文中一共展示了PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doRun
//.........這裏部分代碼省略.........
$codeCoverageReports++;
}
if (isset($arguments['coverageCrap4J'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageHtml'])) {
$codeCoverageReports++;
}
if (isset($arguments['coveragePHP'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageText'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageXml'])) {
$codeCoverageReports++;
}
if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
if ($codeCoverageReports > 0 && !$this->codeCoverageFilter->hasWhitelist()) {
$this->printer->write("Warning:\tNo whitelist configured for code coverage\n");
}
$this->printer->write("\n");
}
if ($codeCoverageReports > 0 && (!extension_loaded('tokenizer') || !$this->runtime->canCollectCodeCoverage())) {
if (!extension_loaded('tokenizer')) {
$this->showExtensionNotLoadedMessage('tokenizer', 'No code coverage will be generated.');
} elseif (!extension_loaded('Xdebug')) {
$this->showExtensionNotLoadedMessage('Xdebug', 'No code coverage will be generated.');
}
$codeCoverageReports = 0;
}
if ($codeCoverageReports > 0) {
$codeCoverage = new PHP_CodeCoverage(null, $this->codeCoverageFilter);
$codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
$codeCoverage->setCheckForUnintentionallyCoveredCode($arguments['strictCoverage']);
$codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
if (isset($arguments['forceCoversAnnotation'])) {
$codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
}
if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
$codeCoverage->setMapTestClassNameToCoveredClassName($arguments['mapTestClassNameToCoveredClassName']);
}
$result->setCodeCoverage($codeCoverage);
}
if ($codeCoverageReports > 1) {
if (isset($arguments['cacheTokens'])) {
$codeCoverage->setCacheTokens($arguments['cacheTokens']);
}
}
if (isset($arguments['jsonLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
}
if (isset($arguments['tapLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
}
if (isset($arguments['junitLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
}
$result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
$result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
$result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
$result->beStrictAboutTestSize($arguments['enforceTimeLimit']);
$result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
$result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
$result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
if ($suite instanceof PHPUnit_Framework_TestSuite) {
示例2: testSetAddUncoveredFilesFromWhitelist
/**
* @covers PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist
*/
public function testSetAddUncoveredFilesFromWhitelist()
{
$this->coverage->setAddUncoveredFilesFromWhitelist(true);
$this->assertAttributeEquals(true, 'addUncoveredFilesFromWhitelist', $this->coverage);
}
示例3: doRun
//.........這裏部分代碼省略.........
}
if (isset($arguments['coverageCrap4J'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageHtml'])) {
$codeCoverageReports++;
}
if (isset($arguments['coveragePHP'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageText'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageXml'])) {
$codeCoverageReports++;
}
if (isset($arguments['noCoverage'])) {
$codeCoverageReports = 0;
}
if ($codeCoverageReports > 0) {
if (!$this->runtime->canCollectCodeCoverage()) {
$this->writeMessage('Error', 'No code coverage driver is available');
$codeCoverageReports = 0;
} elseif (!isset($arguments['whitelist']) && !$this->codeCoverageFilter->hasWhitelist()) {
$this->writeMessage('Error', 'No whitelist configured, no code coverage will be generated');
$codeCoverageReports = 0;
}
}
if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
$this->printer->write("\n");
}
if ($codeCoverageReports > 0) {
$codeCoverage = new PHP_CodeCoverage(null, $this->codeCoverageFilter);
$codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
$codeCoverage->setCheckForUnintentionallyCoveredCode($arguments['strictCoverage']);
$codeCoverage->setCheckForUnexecutedCoveredCode($arguments['strictCoverage']);
$codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
if (isset($arguments['forceCoversAnnotation'])) {
$codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
}
if (isset($arguments['disableCodeCoverageIgnore'])) {
$codeCoverage->setDisableIgnoredLines(true);
}
if (isset($arguments['whitelist'])) {
$this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']);
}
$result->setCodeCoverage($codeCoverage);
}
if ($codeCoverageReports > 1) {
if (isset($arguments['cacheTokens'])) {
$codeCoverage->setCacheTokens($arguments['cacheTokens']);
}
}
if (isset($arguments['jsonLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
}
if (isset($arguments['tapLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
}
if (isset($arguments['teamcityLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TeamCity($arguments['teamcityLogfile']));
}
if (isset($arguments['junitLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
}
$result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
示例4: handleConfiguration
/**
* @param string $filename
* @param PHP_CodeCoverage $coverage
*/
protected function handleConfiguration($filename, \PHP_CodeCoverage $coverage)
{
$filter = $coverage->filter();
$configuration = \PHPUnit_Util_Configuration::getInstance($filename);
$filterConfiguration = $configuration->getFilterConfiguration();
$coverage->setAddUncoveredFilesFromWhitelist($filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']);
$coverage->setProcessUncoveredFilesFromWhitelist($filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']);
foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
$filter->addDirectoryToBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
$filter->addFileToBlacklist($file);
}
foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
$filter->removeDirectoryFromBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
$filter->removeFileFromBlacklist($file);
}
foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
$filter->addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
$filter->addFileToWhitelist($file);
}
foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
$filter->removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
$filter->removeFileFromWhitelist($file);
}
}
示例5: doRun
/**
* @param PHPUnit_Framework_Test $suite
* @param array $arguments
* @return PHPUnit_Framework_TestResult
*/
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
{
$this->handleConfiguration($arguments);
if (isset($arguments['bootstrap'])) {
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
}
if ($arguments['backupGlobals'] === FALSE) {
$suite->setBackupGlobals(FALSE);
}
if ($arguments['backupStaticAttributes'] === TRUE) {
$suite->setBackupStaticAttributes(TRUE);
}
if (is_integer($arguments['repeat'])) {
$suite = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
}
$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['stopOnSkipped']) {
$result->stopOnSkipped(TRUE);
}
if ($this->printer === NULL) {
if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
$this->printer = $arguments['printer'];
} else {
$this->printer = new PHPUnit_TextUI_ResultPrinter(NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
}
}
if (!$this->printer instanceof PHPUnit_Util_Log_TAP && !self::$versionStringPrinted) {
$this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
if (isset($arguments['configuration'])) {
$this->printer->write(sprintf("Configuration read from %s\n\n", $arguments['configuration']->getFilename()));
}
}
foreach ($arguments['listeners'] as $listener) {
$result->addListener($listener);
}
$result->addListener($this->printer);
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger());
}
if (isset($arguments['testdoxHTMLFile'])) {
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
}
if (isset($arguments['testdoxTextFile'])) {
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
}
$codeCoverageReports = 0;
if (extension_loaded('xdebug')) {
if (isset($arguments['coverageClover'])) {
$codeCoverageReports++;
}
if (isset($arguments['reportDirectory'])) {
$codeCoverageReports++;
}
if (isset($arguments['coveragePHP'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageText'])) {
$codeCoverageReports++;
}
}
if ($codeCoverageReports > 0) {
$codeCoverage = new PHP_CodeCoverage(NULL, $this->codeCoverageFilter);
$codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
$codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
if (isset($arguments['forceCoversAnnotation'])) {
$codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
}
if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
$codeCoverage->setMapTestClassNameToCoveredClassName($arguments['mapTestClassNameToCoveredClassName']);
}
$result->setCodeCoverage($codeCoverage);
}
if ($codeCoverageReports > 1) {
if (isset($arguments['cacheTokens'])) {
$codeCoverage->setCacheTokens($arguments['cacheTokens']);
}
}
//.........這裏部分代碼省略.........
示例6:
<?php
require_once 'PHP/CodeCoverage/Autoload.php';
$coverage = new PHP_CodeCoverage();
$filter = $coverage->filter();
$filter->addFileToBlacklist(__FILE__);
$filter->addFileToBlacklist(dirname(__FILE__) . '/auto_append.php');
$filter->addDirectoryToBlacklist(__DIR__ . '/../../../../vendor');
$filter->addDirectoryToBlacklist(__DIR__ . '/../../../../app');
$filter->addDirectoryToWhitelist(__DIR__ . '/../../../../src');
$coverage->setAddUncoveredFilesFromWhitelist(true);
$coverage->setProcessUncoveredFilesFromWhitelist(true);
$coverage->start($_SERVER['SCRIPT_FILENAME']);
示例7: main
/**
* Main method.
*/
public static function main()
{
$input = new ezcConsoleInput();
$input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING));
$input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING));
$input->registerOption(new ezcConsoleOption('', 'php', ezcConsoleInput::TYPE_STRING));
$input->registerOption(new ezcConsoleOption('', 'text', ezcConsoleInput::TYPE_STRING));
$input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
$input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
$input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE));
$input->registerOption(new ezcConsoleOption('', 'add-uncovered', ezcConsoleInput::TYPE_NONE, FALSE));
$input->registerOption(new ezcConsoleOption('', 'process-uncovered', ezcConsoleInput::TYPE_NONE, FALSE));
$input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
$input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
try {
$input->process();
} catch (ezcConsoleOptionException $e) {
print $e->getMessage() . "\n";
exit(1);
}
if ($input->getOption('help')->value) {
self::showHelp();
exit(0);
} else {
if ($input->getOption('version')->value) {
self::printVersionString();
exit(0);
}
}
$arguments = $input->getArguments();
$clover = $input->getOption('clover')->value;
$html = $input->getOption('html')->value;
$php = $input->getOption('php')->value;
$text = $input->getOption('text')->value;
$blacklist = $input->getOption('blacklist')->value;
$whitelist = $input->getOption('whitelist')->value;
$addUncovered = $input->getOption('add-uncovered')->value;
$processUncovered = $input->getOption('process-uncovered')->value;
$merge = $input->getOption('merge')->value;
if (count($arguments) == 1) {
self::printVersionString();
$coverage = new PHP_CodeCoverage();
$filter = $coverage->filter();
if (empty($whitelist)) {
$c = new ReflectionClass('ezcBase');
$filter->addDirectoryToBlacklist(dirname($c->getFileName()));
$c = new ReflectionClass('ezcConsoleInput');
$filter->addDirectoryToBlacklist(dirname($c->getFileName()));
foreach ($blacklist as $item) {
if (is_dir($item)) {
$filter->addDirectoryToBlacklist($item);
} else {
if (is_file($item)) {
$filter->addFileToBlacklist($item);
}
}
}
} else {
$coverage->setAddUncoveredFilesFromWhitelist($addUncovered);
$coverage->setProcessUncoveredFilesFromWhitelist($processUncovered);
foreach ($whitelist as $item) {
if (is_dir($item)) {
$filter->addDirectoryToWhitelist($item);
} else {
if (is_file($item)) {
$filter->addFileToWhitelist($item);
}
}
}
}
if (!$merge) {
$coverage->start('phpcov');
require $arguments[0];
$coverage->stop();
} else {
$finder = new Symfony\Component\Finder\Finder();
$finder->in($arguments[0])->name('*.cov');
foreach ($finder as $file) {
$coverage->merge(unserialize(file_get_contents($file->getRealpath())));
}
}
if ($clover) {
$writer = new PHP_CodeCoverage_Report_Clover();
$writer->process($coverage, $clover);
}
if ($html) {
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($coverage, $html);
}
if ($php) {
$writer = new PHP_CodeCoverage_Report_PHP();
$writer->process($coverage, $php);
}
if ($text) {
$writer = new PHP_CodeCoverage_Report_Text();
$writer->process($coverage, $text);
}
//.........這裏部分代碼省略.........