/** * Utilizes a dummy constraint to indicate that an assertion has happened. */ public function testProcessObjectFreeze() { $assertionCount = PHPUnit_Framework_Assert::getCount(); $this->client->processObjectFreeze(); $newAssertionCount = PHPUnit_Framework_Assert::getCount(); $this->assertGreaterThan($assertionCount, $newAssertionCount); }
public function run(PHPUnit_Framework_TestResult $result = null) { PHPUnit_Framework_Assert::resetCount(); if ($result === NULL) { $result = new PHPUnit_Framework_TestResult(); } $this->suite->publishTestArticles(); // Add articles needed by the tests. $backend = new ParserTestSuiteBackend(); $result->startTest($this); // Support the transition to PHPUnit 3.5 where PHPUnit_Util_Timer is replaced with PHP_Timer if (class_exists('PHP_Timer')) { PHP_Timer::start(); } else { PHPUnit_Util_Timer::start(); } $r = false; try { # Run the test. # On failure, the subclassed backend will throw an exception with # the details. $pt = new PHPUnitParserTest(); $r = $pt->runTest($this->test['test'], $this->test['input'], $this->test['result'], $this->test['options'], $this->test['config']); } catch (PHPUnit_Framework_AssertionFailedError $e) { // PHPUnit_Util_Timer -> PHP_Timer support (see above) if (class_exists('PHP_Timer')) { $result->addFailure($this, $e, PHP_Timer::stop()); } else { $result->addFailure($this, $e, PHPUnit_Util_Timer::stop()); } } catch (Exception $e) { // PHPUnit_Util_Timer -> PHP_Timer support (see above) if (class_exists('PHP_Timer')) { $result->addFailure($this, $e, PHP_Timer::stop()); } else { $result->addFailure($this, $e, PHPUnit_Util_Timer::stop()); } } // PHPUnit_Util_Timer -> PHP_Timer support (see above) if (class_exists('PHP_Timer')) { $result->endTest($this, PHP_Timer::stop()); } else { $result->endTest($this, PHPUnit_Util_Timer::stop()); } $backend->recorder->record($this->test['test'], $r); $this->addToAssertionCount(PHPUnit_Framework_Assert::getCount()); return $result; }
/** * 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); } 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); } elseif ($failure === true) { $this->addFailure($test, $e, $time); } elseif ($warning === true) { $this->addWarning($test, $e, $time); } elseif ($this->beStrictAboutTestsThatDoNotTestAnything && $test->getNumAssertions() == 0) { $this->addFailure($test, new PHPUnit_Framework_RiskyTestError('This test did not perform any assertions'), $time); } elseif ($this->beStrictAboutOutputDuringTests && $test->hasOutput()) { $this->addFailure($test, new PHPUnit_Framework_OutputError(sprintf('This test printed output: %s', $test->getActualOutput())), $time); } elseif ($this->beStrictAboutTodoAnnotatedTests && $test instanceof PHPUnit_Framework_TestCase) { $annotations = $test->getAnnotations(); if (isset($annotations['method']['todo'])) { $this->addFailure($test, new PHPUnit_Framework_RiskyTestError('Test method is annotated with @todo'), $time); } } $this->endTest($test, $time); }
/** * 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); }
/** * 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); }
protected function assertionCounterEnd() { $this->numAssertions = \PHPUnit_Framework_Assert::getCount(); }
/** * 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; $risky = 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(); } } $collectCodeCoverage = $this->codeCoverage !== null && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning; if ($collectCodeCoverage) { // We need to blacklist test source files when no whitelist is used. if (!$this->codeCoverage->filter()->hasWhitelist()) { $classes = $this->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->beStrictAboutTestSize && 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_RiskyTestError) { $risky = true; } elseif ($e instanceof PHPUnit_Framework_IncompleteTestError) { $incomplete = true; } elseif ($e instanceof PHPUnit_Framework_SkippedTestError) { $skipped = true; } } catch (PHPUnit_Framework_Exception $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 ($this->beStrictAboutTestsThatDoNotTestAnything && $test->getNumAssertions() == 0) { $risky = true; } if ($collectCodeCoverage) { $append = !$risky && !$incomplete && !$skipped; $linesToBeCovered = array(); $linesToBeUsed = array(); 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_Exception_UnintentionallyCoveredCode $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); } 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); } elseif ($failure === true) { $this->addFailure($test, $e, $time); } elseif ($this->beStrictAboutTestsThatDoNotTestAnything && $test->getNumAssertions() == 0) { $this->addFailure($test, new PHPUnit_Framework_RiskyTestError('This test did not perform any assertions'), $time); } elseif ($this->beStrictAboutOutputDuringTests && $test->hasOutput()) { $this->addFailure($test, new PHPUnit_Framework_OutputError(sprintf('This test printed output: %s', $test->getActualOutput())), $time); } elseif ($this->beStrictAboutTodoAnnotatedTests && $test instanceof PHPUnit_Framework_TestCase) { $annotations = $test->getAnnotations(); if (isset($annotations['method']['todo'])) { $this->addFailure($test, new PHPUnit_Framework_RiskyTestError('Test method is annotated with @todo'), $time); } } $this->endTest($test, $time); }
/** * 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); } } } } $this->endTest($test, $time); }
public function run(PHPUnit_Framework_TestResult $result = NULL) { PHPUnit_Framework_Assert::resetCount(); if ($result === NULL) { $result = new PHPUnit_Framework_TestResult(); } $t = MediaWikiParserTestSuite::$iter->current(); $k = MediaWikiParserTestSuite::$iter->key(); if (!MediaWikiParserTestSuite::$iter->valid()) { return; } // The only way this should happen is if the parserTest.txt // file were modified while the script is running. if ($k != $this->number) { $i = $this->number; wfDie("I got confused!\n"); } $result->startTest($this); PHPUnit_Util_Timer::start(); $r = false; try { $r = MediaWikiParserTestSuite::$parser->runTest($t['test'], $t['input'], $t['result'], $t['options'], $t['config']); PHPUnit_Framework_Assert::assertTrue(true, $t['test']); } catch (PHPUnit_Framework_AssertionFailedError $e) { $result->addFailure($this, $e, PHPUnit_Util_Timer::stop()); } catch (Exception $e) { $result->addError($this, $e, PHPUnit_Util_Timer::stop()); } PHPUnit_Framework_Assert::assertTrue(true, $t['test']); $result->endTest($this, PHPUnit_Util_Timer::stop()); MediaWikiParserTestSuite::$parser->recorder->record($t['test'], $r); MediaWikiParserTestSuite::$iter->next(); $this->addToAssertionCount(PHPUnit_Framework_Assert::getCount()); return $result; }
/** * This runs the actual test, and is intended to be run against the testsuite * that is output by the 'suite' function **/ public function run(\PHPUnit_Framework_TestResult $result = NULL) { if ($result === NULL) { $result = new \PHPUnit_Framework_TestResult(); } $this->_result = $result; $this->_result->startTest($this); \PHPUnit_Framework_Assert::resetCount(); \PHP_Timer::start(); $stop_time = NULL; try { //Run the before callbacks if ($this->_setup_callback !== null) { call_user_func($this->_setup_callback, $this); } foreach ($this->_before_chain as $current_before) { if ($current_before !== null) { call_user_func($current_before, $this); } } // Part of the shim to allow us to use PHPUnit's runTest method $refClass = new \ReflectionClass($this); for ($i = 0; $i < 20; $i++) { $refClass = $refClass->getParentClass(); if ($refClass->getName() === 'PHPUnit_Framework_TestCase') { break; } } $refProperty = $refClass->getProperty('name'); $refProperty->setAccessible(true); $refProperty->setValue($this, 'run_current_test'); $this->runTest(); $this->verifyMockObjects(); $this->addToAssertionCount(\PHPUnit_Framework_Assert::getCount()); if (!$this->assertion_count) { $this->markTestIncomplete('This spec does not have any expectation'); } //Run the after callbacks if ($this->_teardown_callback !== null) { call_user_func($this->_teardown_callback, $this); } } catch (\PHPUnit_Framework_AssertionFailedError $e) { $stop_time = \PHP_Timer::stop(); $this->_result->addFailure($this, $e, $stop_time); } catch (\Esperance\Error $e) { $stop_time = \PHP_Timer::stop(); $this->_result->addFailure($this, new \PHPUnit_Framework_AssertionFailedError($e->getMessage(), $e->getCode(), $e), $stop_time); } catch (\Exception $e) { $stop_time = \PHP_Timer::stop(); $this->_result->addError($this, $e, $stop_time); } if ($stop_time === NULL) { $stop_time = \PHP_Timer::stop(); } $this->_result->endTest($this, $stop_time); return $this->_result; }
/** * 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); }
/** * {@inheritdoc} */ public function endTest(PHPUnit_Framework_Test $test, $time) { $this->phpUnitTestCounter->addAssert(\PHPUnit_Framework_Assert::getCount()); }
/** * A test ended. * * @param \PHPUnit_Framework_Test $test */ public function endTest(\PHPUnit_Framework_Test $test, $time) { if (!$test instanceof \PHPUnit_Framework_TestCase) { return; } $assertions = \PHPUnit_Framework_Assert::getCount(); if ($assertions > $this->alertThreshold) { $this->addAssertiveTest($test, $assertions); } }