本文整理汇总了PHP中PHPUnit_Framework_TestResult::setCodeCoverage方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestResult::setCodeCoverage方法的具体用法?PHP PHPUnit_Framework_TestResult::setCodeCoverage怎么用?PHP PHPUnit_Framework_TestResult::setCodeCoverage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestResult
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestResult::setCodeCoverage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testThatAfterSuiteRespectsRemoteFalseSetting
public function testThatAfterSuiteRespectsRemoteFalseSetting()
{
$reflection = new ReflectionClass('Codeception\\Subscriber\\RemoteCodeCoverage');
$settingsProperty = $reflection->getProperty('settings');
$settingsProperty->setAccessible(true);
/** @var $codeCoverageMock \Codeception\Subscriber\RemoteCodeCoverage|PHPUnit_Framework_MockObject_MockObject */
$codeCoverageMock = $this->getMockBuilder('Codeception\\Subscriber\\RemoteCodeCoverage')->disableOriginalConstructor()->setMethods(array('getRemoteConnectionModule'))->getMock();
$settingsProperty->setValue($codeCoverageMock, array('enabled' => true, 'remote' => false));
/** @var $testSuite PHPUnit_Framework_TestSuite|PHPUnit_Framework_MockObject_MockObject */
$testSuite = $this->getMock('PHPUnit_Framework_TestSuite', array(), array(), '', false);
$testResult = new PHPUnit_Framework_TestResult();
$testResult->setCodeCoverage(new \PHP_CodeCoverage());
$suiteEvent = new Suite($testSuite, $testResult);
$codeCoverageMock->beforeSuite($suiteEvent);
}
示例2: run
/**
* Run a test
*/
public function run(PHPUnit_Framework_TestSuite $suite)
{
$res = new PHPUnit_Framework_TestResult();
if ($this->codecoverage) {
$whitelist = CoverageMerger::getWhiteList($this->project);
$this->codecoverage->filter()->addFilesToWhiteList($whitelist);
$res->setCodeCoverage($this->codecoverage);
}
$res->addListener($this);
foreach ($this->formatters as $formatter) {
$res->addListener($formatter);
}
/* Set PHPUnit error handler */
if ($this->useCustomErrorHandler) {
$oldErrorHandler = set_error_handler(array($this, 'handleError'), E_ALL | E_STRICT);
}
$suite->run($res, false, $this->groups, $this->excludeGroups, $this->processIsolation);
foreach ($this->formatters as $formatter) {
$formatter->processResult($res);
}
/* Restore Phing error handler */
if ($this->useCustomErrorHandler) {
restore_error_handler();
}
if ($this->codecoverage) {
CoverageMerger::merge($this->project, $this->codecoverage->getData());
}
if ($res->errorCount() != 0) {
$this->retCode = self::ERRORS;
} else {
if ($res->failureCount() != 0) {
$this->retCode = self::FAILURES;
} else {
if ($res->notImplementedCount() != 0) {
$this->retCode = self::INCOMPLETES;
} else {
if ($res->skippedCount() != 0) {
$this->retCode = self::SKIPPED;
}
}
}
}
}
示例3: run
/**
* Run a test
*
* @param PHPUnit_Framework_TestSuite $suite
*/
public function run(PHPUnit_Framework_TestSuite $suite)
{
$res = new PHPUnit_Framework_TestResult();
if ($this->codecoverage) {
$whitelist = CoverageMerger::getWhiteList($this->project);
$this->codecoverage->filter()->addFilesToWhiteList($whitelist);
$res->setCodeCoverage($this->codecoverage);
}
$res->addListener($this);
foreach ($this->formatters as $formatter) {
$res->addListener($formatter);
}
/* Set PHPUnit error handler */
if ($this->useCustomErrorHandler) {
$oldErrorHandler = set_error_handler(array($this, 'handleError'), E_ALL | E_STRICT);
}
$version = PHPUnit_Runner_Version::id();
if (version_compare($version, '4.0.0') >= 0) {
$this->injectFilters($suite);
$suite->run($res);
} else {
$suite->run($res, false, $this->groups, $this->excludeGroups, $this->processIsolation);
}
foreach ($this->formatters as $formatter) {
$formatter->processResult($res);
}
/* Restore Phing error handler */
if ($this->useCustomErrorHandler) {
restore_error_handler();
}
if ($this->codecoverage) {
CoverageMerger::merge($this->project, $this->codecoverage->getData());
}
$this->checkResult($res);
}
示例4: applyFilter
public function applyFilter(\PHPUnit_Framework_TestResult $result)
{
$result->setCodeCoverage(new DummyCodeCoverage());
Filter::setup($this->coverage)->whiteList($this->filters)->blackList($this->filters);
$result->setCodeCoverage($this->coverage);
}
示例5: runTests
//.........这里部分代码省略.........
}
// XDEBUG seem to cause problems with test execution :-(
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
ini_set('max_execution_time', 0);
$this->setUp();
// Optionally skip certain tests
$skipTests = array();
if ($this->request->getVar('SkipTests')) {
$skipTests = explode(',', $this->request->getVar('SkipTests'));
}
$abstractClasses = array();
foreach ($classList as $className) {
// Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this.
class_exists($className);
$reflection = new ReflectionClass($className);
if ($reflection->isAbstract()) {
array_push($abstractClasses, $className);
}
}
$classList = array_diff($classList, $skipTests);
// run tests before outputting anything to the client
$suite = new PHPUnit_Framework_TestSuite();
natcasesort($classList);
foreach ($classList as $className) {
// Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this.
class_exists($className);
$suite->addTest(new SapphireTestSuite($className));
}
// Remove the error handler so that PHPUnit can add its own
restore_error_handler();
// CUSTOMISATION
if (Director::is_cli()) {
if ($reporterClass = $this->request->requestVar('reporter')) {
$clazz = $reporterClass;
} else {
if (isset($TESTING_CONFIG['reporter'])) {
$clazz = $TESTING_CONFIG['reporter'];
} else {
$clazz = "CliTestReporter";
}
}
} else {
$clazz = "SapphireTestReporter";
}
// END CUSTOMISATION
// CUSTOMISATION
$outputFile = null;
if ($TESTING_CONFIG['logfile']) {
$outputFile = BASE_PATH . '/' . $TESTING_CONFIG['logfile'];
}
$reporter = new $clazz($outputFile);
$default = self::$default_reporter;
self::$default_reporter->writeHeader("Sapphire Test Runner");
if (count($classList) > 1) {
self::$default_reporter->writeInfo("All Tests", "Running test cases: " . implode(",", $classList));
} else {
self::$default_reporter->writeInfo($classList[0], "");
}
$results = new PHPUnit_Framework_TestResult();
$results->addListener($reporter);
if ($coverage === true) {
$coverer = $this->getCodeCoverage();
$results->setCodeCoverage($coverer);
$suite->run($results);
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($coverer, Director::baseFolder() . '/ssautesting/html/code-coverage-report');
} else {
$suite->run($results);
}
if (!Director::is_cli()) {
echo '<div class="trace">';
}
if (method_exists($reporter, 'writeResults')) {
$reporter->writeResults($outputFile);
} else {
$reporter->flush();
}
// END CUSTOMISATION
$endTime = microtime(true);
if (Director::is_cli()) {
echo "\n\nTotal time: " . round($endTime - $startTime, 3) . " seconds\n";
} else {
echo "<p>Total time: " . round($endTime - $startTime, 3) . " seconds</p>\n";
}
if (!Director::is_cli()) {
echo '</div>';
}
// Put the error handlers back
Debug::loadErrorHandlers();
if (!Director::is_cli()) {
self::$default_reporter->writeFooter();
}
$this->tearDown();
// Todo: we should figure out how to pass this data back through Director more cleanly
if (Director::is_cli() && $results->failureCount() + $results->errorCount() > 0) {
exit(2);
}
}