本文整理汇总了PHP中PHPUnit_Framework_TestResult::useXdebug方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestResult::useXdebug方法的具体用法?PHP PHPUnit_Framework_TestResult::useXdebug怎么用?PHP PHPUnit_Framework_TestResult::useXdebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestResult
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestResult::useXdebug方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
*/
public function run(PHPUnit_Framework_Test $test)
{
PHPUnit_Framework_Assert::resetCount();
$error = FALSE;
$failure = FALSE;
$incomplete = FALSE;
$skipped = FALSE;
$this->startTest($test);
$errorHandlerSet = FALSE;
if ($this->convertErrorsToExceptions) {
$oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
if ($oldErrorHandler === NULL) {
$errorHandlerSet = TRUE;
} else {
restore_error_handler();
}
}
if (self::$xdebugLoaded === NULL) {
self::$xdebugLoaded = extension_loaded('xdebug');
self::$useXdebug = self::$xdebugLoaded;
}
$useXdebug = self::$useXdebug && $this->collectCodeCoverageInformation && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning;
if ($useXdebug) {
$this->codeCoverage->start($test);
}
PHP_Timer::start();
try {
$test->runBare();
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = TRUE;
if ($e instanceof PHPUnit_Framework_IncompleteTestError) {
$incomplete = TRUE;
} else {
if ($e instanceof PHPUnit_Framework_SkippedTestError) {
$skipped = TRUE;
}
}
} catch (Exception $e) {
$error = TRUE;
}
$time = PHP_Timer::stop();
$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
if ($this->strictMode && $test->getNumAssertions() == 0) {
$incomplete = TRUE;
}
if ($useXdebug) {
$data = $this->codeCoverage->stop(FALSE);
if (!$incomplete && !$skipped) {
if ($this->collectRawCodeCoverageInformation) {
$this->rawCodeCoverageInformation[] = $data;
} else {
$filterGroups = array('DEFAULT', 'TESTS');
if (!defined('PHPUNIT_TESTSUITE')) {
$filterGroups[] = 'PHPUNIT';
}
$this->codeCoverage->append($data, $test, $filterGroups);
}
}
unset($data);
}
if ($errorHandlerSet === TRUE) {
restore_error_handler();
}
if ($error === TRUE) {
$this->addError($test, $e, $time);
} else {
if ($failure === TRUE) {
$this->addFailure($test, $e, $time);
} else {
if ($this->strictMode && $test->getNumAssertions() == 0) {
$this->addFailure($test, new PHPUnit_Framework_IncompleteTestError('This test did not perform any assertions'), $time);
}
}
}
$this->endTest($test, $time);
}
示例2: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
*/
public function run(PHPUnit_Framework_Test $test)
{
PHPUnit_Framework_Assert::resetCount();
$error = FALSE;
$failure = FALSE;
$this->startTest($test);
$errorHandlerSet = FALSE;
if ($this->convertErrorsToExceptions) {
$oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
if ($oldErrorHandler === NULL) {
$errorHandlerSet = TRUE;
} else {
restore_error_handler();
}
}
if (self::$xdebugLoaded === NULL) {
self::$xdebugLoaded = extension_loaded('xdebug');
self::$useXdebug = self::$xdebugLoaded;
}
$useXdebug = self::$useXdebug && $this->collectCodeCoverageInformation && !$test instanceof PHPUnit_Extensions_SeleniumTestCase;
if ($useXdebug) {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}
PHPUnit_Util_Timer::start();
try {
$test->runBare();
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = TRUE;
} catch (Exception $e) {
$error = TRUE;
}
$time = PHPUnit_Util_Timer::stop();
if ($useXdebug) {
$codeCoverage = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
$this->appendCodeCoverageInformation($test, $codeCoverage);
}
if ($errorHandlerSet === TRUE) {
restore_error_handler();
}
$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
if ($error === TRUE) {
$this->addError($test, $e, $time);
} else {
if ($failure === TRUE) {
$this->addFailure($test, $e, $time);
}
}
$this->endTest($test, $time);
}
示例3: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
* @access public
*/
public function run(PHPUnit_Framework_Test $test)
{
$error = FALSE;
$failure = FALSE;
$this->startTest($test);
$errorHandlerSet = FALSE;
if (self::$isPHP52 === NULL) {
if (version_compare(phpversion(), '5.2.0RC1', '>=')) {
self::$isPHP52 = TRUE;
} else {
self::$isPHP52 = FALSE;
}
}
if (self::$isPHP52) {
$oldErrorHandler = set_error_handler('PHPUnit_Util_ErrorHandler', E_RECOVERABLE_ERROR | E_USER_ERROR | E_NOTICE | E_STRICT);
} else {
$oldErrorHandler = set_error_handler('PHPUnit_Util_ErrorHandler', E_USER_ERROR | E_NOTICE | E_STRICT);
}
if ($oldErrorHandler === NULL) {
$errorHandlerSet = TRUE;
} else {
restore_error_handler();
}
if (self::$xdebugLoaded === NULL) {
self::$xdebugLoaded = extension_loaded('xdebug');
self::$useXdebug = self::$xdebugLoaded;
}
$useXdebug = self::$useXdebug && $this->collectCodeCoverageInformation && !$test instanceof PHPUnit_Extensions_SeleniumTestCase;
if ($useXdebug) {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}
PHPUnit_Util_Timer::start();
try {
$test->runBare();
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = TRUE;
} catch (Exception $e) {
$error = TRUE;
}
$time = PHPUnit_Util_Timer::stop();
if ($useXdebug) {
$this->codeCoverageInformation[] = array('test' => $test, 'files' => xdebug_get_code_coverage());
xdebug_stop_code_coverage();
}
if ($errorHandlerSet === TRUE) {
restore_error_handler();
}
if ($error === TRUE) {
$this->addError($test, $e, $time);
} else {
if ($failure === TRUE) {
$this->addFailure($test, $e, $time);
}
}
$this->endTest($test, $time);
$this->time += $time;
}
示例4: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
*/
public function run(PHPUnit_Framework_Test $test)
{
PHPUnit_Framework_Assert::resetCount();
$error = FALSE;
$failure = FALSE;
$incomplete = FALSE;
$skipped = FALSE;
$this->startTest($test);
$errorHandlerSet = FALSE;
if ($this->convertErrorsToExceptions) {
$oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
if ($oldErrorHandler === NULL) {
$errorHandlerSet = TRUE;
} else {
restore_error_handler();
}
}
if (self::$xdebugLoaded === NULL) {
self::$xdebugLoaded = extension_loaded('xdebug');
self::$useXdebug = self::$xdebugLoaded;
}
$useXdebug = self::$useXdebug && $this->codeCoverage !== NULL && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning;
if ($useXdebug) {
// We need to blacklist test source files when no whitelist is used.
if (!$this->codeCoverage->filter()->hasWhitelist()) {
$classes = PHPUnit_Util_Class::getHierarchy(get_class($test), TRUE);
foreach ($classes as $class) {
$this->codeCoverage->filter()->addFileToBlacklist($class->getFileName());
}
}
$this->codeCoverage->start($test);
}
PHP_Timer::start();
try {
if (!$test instanceof PHPUnit_Framework_Warning && $this->strictMode && 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(array($test, 'runBare'), array(), $_timeout);
} else {
$test->runBare();
}
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = TRUE;
if ($e instanceof PHPUnit_Framework_IncompleteTestError) {
$incomplete = TRUE;
} else {
if ($e instanceof PHPUnit_Framework_SkippedTestError) {
$skipped = TRUE;
}
}
} catch (Exception $e) {
$error = TRUE;
}
$time = PHP_Timer::stop();
$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
if ($this->strictMode && $test->getNumAssertions() == 0) {
$incomplete = TRUE;
}
if ($useXdebug) {
try {
$this->codeCoverage->stop(!$incomplete && !$skipped);
} catch (PHP_CodeCoverage_Exception $cce) {
$error = TRUE;
if (!isset($e)) {
$e = $cce;
}
}
}
if ($errorHandlerSet === TRUE) {
restore_error_handler();
}
if ($error === TRUE) {
$this->addError($test, $e, $time);
} else {
if ($failure === TRUE) {
$this->addFailure($test, $e, $time);
} else {
if ($this->strictMode && $test->getNumAssertions() == 0) {
$this->addFailure($test, new PHPUnit_Framework_IncompleteTestError('This test did not perform any assertions'), $time);
} else {
if ($this->strictMode && $test->hasOutput()) {
$this->addFailure($test, new PHPUnit_Framework_OutputError(sprintf('This test printed output: %s', $test->getActualOutput())), $time);
}
}
}
//.........这里部分代码省略.........
示例5: run
/**
* Runs a TestCase.
*
* @param PHPUnit_Framework_Test $test
*/
public function run(PHPUnit_Framework_Test $test)
{
PHPUnit_Framework_Assert::resetCount();
$error = FALSE;
$failure = FALSE;
$incomplete = FALSE;
$skipped = FALSE;
$this->startTest($test);
$errorHandlerSet = FALSE;
if ($this->convertErrorsToExceptions) {
$oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
if ($oldErrorHandler === NULL) {
$errorHandlerSet = TRUE;
} else {
restore_error_handler();
}
}
if (self::$xdebugLoaded === NULL) {
self::$xdebugLoaded = extension_loaded('xdebug');
self::$useXdebug = self::$xdebugLoaded;
}
$useXdebug = self::$useXdebug && $this->codeCoverage !== NULL && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning;
if ($useXdebug) {
$this->codeCoverage->start($test);
}
PHP_Timer::start();
try {
$test->runBare();
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$failure = TRUE;
if ($e instanceof PHPUnit_Framework_IncompleteTestError) {
$incomplete = TRUE;
} else {
if ($e instanceof PHPUnit_Framework_SkippedTestError) {
$skipped = TRUE;
}
}
} catch (Exception $e) {
$error = TRUE;
}
$time = PHP_Timer::stop();
$test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
if ($this->strictMode && $test->getNumAssertions() == 0) {
$incomplete = TRUE;
}
if ($useXdebug) {
try {
$this->codeCoverage->stop(!$incomplete && !$skipped);
} catch (PHP_CodeCoverage_Exception $cce) {
$error = TRUE;
if (!isset($e)) {
$e = $cce;
}
}
}
if ($errorHandlerSet === TRUE) {
restore_error_handler();
}
if ($error === TRUE) {
$this->addError($test, $e, $time);
} else {
if ($failure === TRUE) {
$this->addFailure($test, $e, $time);
} else {
if ($this->strictMode && $test->getNumAssertions() == 0) {
$this->addFailure($test, new PHPUnit_Framework_IncompleteTestError('This test did not perform any assertions'), $time);
} else {
if ($this->strictMode && $test->hasOutput()) {
$this->addFailure($test, new PHPUnit_Framework_OutputError(sprintf('This test printed output: %s', $test->getActualOutput())), $time);
}
}
}
}
$this->endTest($test, $time);
}