Source of file TestResult.php
Size: 30,169 Bytes - Last Modified: 2014-08-22T02:09:07+02:00
/home/theseer/storage/php/phpunit/src/src/Framework/TestResult.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126 | <?php /** * PHPUnit * * Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of Sebastian Bergmann nor the names of his * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package PHPUnit * @subpackage Framework * @author Sebastian Bergmann <sebastian@phpunit.de> * @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de> * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since File available since Release 2.0.0 */ /** * A TestResult collects the results of executing a test case. * * @package PHPUnit * @subpackage Framework * @author Sebastian Bergmann <sebastian@phpunit.de> * @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de> * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @link http://www.phpunit.de/ * @since Class available since Release 2.0.0 */ class PHPUnit_Framework_TestResult implements Countable { /** * @var array */ protected $passed = array(); /** * @var array */ protected $errors = array(); /** * @var array */ protected $failures = array(); /** * @var array */ protected $notImplemented = array(); /** * @var array */ protected $risky = array(); /** * @var array */ protected $skipped = array(); /** * @var array */ protected $listeners = array(); /** * @var integer */ protected $runTests = 0; /** * @var float */ protected $time = 0; /** * @var PHPUnit_Framework_TestSuite */ protected $topTestSuite = null; /** * Code Coverage information. * * @var PHP_CodeCoverage */ protected $codeCoverage; /** * @var boolean */ protected $convertErrorsToExceptions = true; /** * @var boolean */ protected $stop = false; /** * @var boolean */ protected $stopOnError = false; /** * @var boolean */ protected $stopOnFailure = false; /** * @var boolean */ protected $beStrictAboutTestsThatDoNotTestAnything = false; /** * @var boolean */ protected $beStrictAboutOutputDuringTests = false; /** * @var boolean */ protected $beStrictAboutTestSize = false; /** * @var boolean */ protected $beStrictAboutTodoAnnotatedTests = false; /** * @var boolean */ protected $stopOnRisky = false; /** * @var boolean */ protected $stopOnIncomplete = false; /** * @var boolean */ protected $stopOnSkipped = false; /** * @var boolean */ protected $lastTestFailed = false; /** * @var integer */ protected $timeoutForSmallTests = 1; /** * @var integer */ protected $timeoutForMediumTests = 10; /** * @var integer */ protected $timeoutForLargeTests = 60; /** * Registers a TestListener. * * @param PHPUnit_Framework_TestListener */ public function addListener(PHPUnit_Framework_TestListener $listener) { $this->listeners[] = $listener; } /** * Unregisters a TestListener. * * @param PHPUnit_Framework_TestListener $listener */ public function removeListener(PHPUnit_Framework_TestListener $listener) { foreach ($this->listeners as $key => $_listener) { if ($listener === $_listener) { unset($this->listeners[$key]); } } } /** * Flushes all flushable TestListeners. * * @since Method available since Release 3.0.0 */ public function flushListeners() { foreach ($this->listeners as $listener) { if ($listener instanceof PHPUnit_Util_Printer) { $listener->flush(); } } } /** * Adds an error to the list of errors. * * @param PHPUnit_Framework_Test $test * @param Exception $e * @param float $time */ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { if ($e instanceof PHPUnit_Framework_RiskyTest) { $this->risky[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addRiskyTest'; if ($this->stopOnRisky) { $this->stop(); } } elseif ($e instanceof PHPUnit_Framework_IncompleteTest) { $this->notImplemented[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addIncompleteTest'; if ($this->stopOnIncomplete) { $this->stop(); } } elseif ($e instanceof PHPUnit_Framework_SkippedTest) { $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addSkippedTest'; if ($this->stopOnSkipped) { $this->stop(); } } else { $this->errors[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addError'; if ($this->stopOnError || $this->stopOnFailure) { $this->stop(); } } foreach ($this->listeners as $listener) { $listener->$notifyMethod($test, $e, $time); } $this->lastTestFailed = true; $this->time += $time; } /** * Adds a failure to the list of failures. * The passed in exception caused the failure. * * @param PHPUnit_Framework_Test $test * @param PHPUnit_Framework_AssertionFailedError $e * @param float $time */ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { if ($e instanceof PHPUnit_Framework_RiskyTest) { $this->risky[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addRiskyTest'; if ($this->stopOnRisky) { $this->stop(); } } elseif ($e instanceof PHPUnit_Framework_IncompleteTest) { $this->notImplemented[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addIncompleteTest'; if ($this->stopOnIncomplete) { $this->stop(); } } elseif ($e instanceof PHPUnit_Framework_SkippedTest) { $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addSkippedTest'; if ($this->stopOnSkipped) { $this->stop(); } } else { $this->failures[] = new PHPUnit_Framework_TestFailure($test, $e); $notifyMethod = 'addFailure'; if ($this->stopOnFailure) { $this->stop(); } } foreach ($this->listeners as $listener) { $listener->$notifyMethod($test, $e, $time); } $this->lastTestFailed = true; $this->time += $time; } /** * Informs the result that a testsuite will be started. * * @param PHPUnit_Framework_TestSuite $suite * @since Method available since Release 2.2.0 */ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { if ($this->topTestSuite === null) { $this->topTestSuite = $suite; } foreach ($this->listeners as $listener) { $listener->startTestSuite($suite); } } /** * Informs the result that a testsuite was completed. * * @param PHPUnit_Framework_TestSuite $suite * @since Method available since Release 2.2.0 */ public function endTestSuite(PHPUnit_Framework_TestSuite $suite) { foreach ($this->listeners as $listener) { $listener->endTestSuite($suite); } } /** * Informs the result that a test will be started. * * @param PHPUnit_Framework_Test $test */ public function startTest(PHPUnit_Framework_Test $test) { $this->lastTestFailed = false; $this->runTests += count($test); foreach ($this->listeners as $listener) { $listener->startTest($test); } } /** * Informs the result that a test was completed. * * @param PHPUnit_Framework_Test $test * @param float $time */ public function endTest(PHPUnit_Framework_Test $test, $time) { foreach ($this->listeners as $listener) { $listener->endTest($test, $time); } if (!$this->lastTestFailed && $test instanceof PHPUnit_Framework_TestCase) { $class = get_class($test); $key = $class . '::' . $test->getName(); $this->passed[$key] = array( 'result' => $test->getResult(), 'size' => PHPUnit_Util_Test::getSize( $class, $test->getName(false) ) ); $this->time += $time; } } /** * Returns true if no risky test occurred. * * @return boolean * @since Method available since Release 4.0.0 */ public function allHarmless() { return $this->riskyCount() == 0; } /** * Gets the number of risky tests. * * @return integer * @since Method available since Release 4.0.0 */ public function riskyCount() { return count($this->risky); } /** * Returns true if no incomplete test occurred. * * @return boolean */ public function allCompletelyImplemented() { return $this->notImplementedCount() == 0; } /** * Gets the number of incomplete tests. * * @return integer */ public function notImplementedCount() { return count($this->notImplemented); } /** * Returns an Enumeration for the risky tests. * * @return array * @since Method available since Release 4.0.0 */ public function risky() { return $this->risky; } /** * Returns an Enumeration for the incomplete tests. * * @return array */ public function notImplemented() { return $this->notImplemented; } /** * Returns true if no test has been skipped. * * @return boolean * @since Method available since Release 3.0.0 */ public function noneSkipped() { return $this->skippedCount() == 0; } /** * Gets the number of skipped tests. * * @return integer * @since Method available since Release 3.0.0 */ public function skippedCount() { return count($this->skipped); } /** * Returns an Enumeration for the skipped tests. * * @return array * @since Method available since Release 3.0.0 */ public function skipped() { return $this->skipped; } /** * Gets the number of detected errors. * * @return integer */ public function errorCount() { return count($this->errors); } /** * Returns an Enumeration for the errors. * * @return array */ public function errors() { return $this->errors; } /** * Gets the number of detected failures. * * @return integer */ public function failureCount() { return count($this->failures); } /** * Returns an Enumeration for the failures. * * @return array */ public function failures() { return $this->failures; } /** * Returns the names of the tests that have passed. * * @return array * @since Method available since Release 3.4.0 */ public function passed() { return $this->passed; } /** * Returns the (top) test suite. * * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.0.0 */ public function topTestSuite() { return $this->topTestSuite; } /** * Returns whether code coverage information should be collected. * * @return boolean If code coverage should be collected * @since Method available since Release 3.2.0 */ public function getCollectCodeCoverageInformation() { return $this->codeCoverage !== null; } /** * 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 ($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 ); } } 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 ); } $this->endTest($test, $time); } /** * Gets the number of run tests. * * @return integer */ public function count() { return $this->runTests; } /** * Checks whether the test run should stop. * * @return boolean */ public function shouldStop() { return $this->stop; } /** * Marks that the test run should stop. * */ public function stop() { $this->stop = true; } /** * Returns the PHP_CodeCoverage object. * * @return PHP_CodeCoverage * @since Method available since Release 3.5.0 */ public function getCodeCoverage() { return $this->codeCoverage; } /** * Sets the PHP_CodeCoverage object. * * @param PHP_CodeCoverage $codeCoverage * @since Method available since Release 3.6.0 */ public function setCodeCoverage(PHP_CodeCoverage $codeCoverage) { $this->codeCoverage = $codeCoverage; } /** * Enables or disables the error-to-exception conversion. * * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.2.14 */ public function convertErrorsToExceptions($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->convertErrorsToExceptions = $flag; } /** * Returns the error-to-exception conversion setting. * * @return boolean * @since Method available since Release 3.4.0 */ public function getConvertErrorsToExceptions() { return $this->convertErrorsToExceptions; } /** * Enables or disables the stopping when an error occurs. * * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.5.0 */ public function stopOnError($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->stopOnError = $flag; } /** * Enables or disables the stopping when a failure occurs. * * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.1.0 */ public function stopOnFailure($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->stopOnFailure = $flag; } /** * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 4.0.0 */ public function beStrictAboutTestsThatDoNotTestAnything($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->beStrictAboutTestsThatDoNotTestAnything = $flag; } /** * @return boolean * @since Method available since Release 4.0.0 */ public function isStrictAboutTestsThatDoNotTestAnything() { return $this->beStrictAboutTestsThatDoNotTestAnything; } /** * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 4.0.0 */ public function beStrictAboutOutputDuringTests($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->beStrictAboutOutputDuringTests = $flag; } /** * @return boolean * @since Method available since Release 4.0.0 */ public function isStrictAboutOutputDuringTests() { return $this->beStrictAboutOutputDuringTests; } /** * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 4.0.0 */ public function beStrictAboutTestSize($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->beStrictAboutTestSize = $flag; } /** * @return boolean * @since Method available since Release 4.0.0 */ public function isStrictAboutTestSize() { return $this->beStrictAboutTestSize; } /** * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 4.2.0 */ public function beStrictAboutTodoAnnotatedTests($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->beStrictAboutTodoAnnotatedTests = $flag; } /** * @return boolean * @since Method available since Release 4.2.0 */ public function isStrictAboutTodoAnnotatedTests() { return $this->beStrictAboutTodoAnnotatedTests; } /** * Enables or disables the stopping for risky tests. * * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 4.0.0 */ public function stopOnRisky($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->stopOnRisky = $flag; } /** * Enables or disables the stopping for incomplete tests. * * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.5.0 */ public function stopOnIncomplete($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->stopOnIncomplete = $flag; } /** * Enables or disables the stopping for skipped tests. * * @param boolean $flag * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.1.0 */ public function stopOnSkipped($flag) { if (!is_bool($flag)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean'); } $this->stopOnSkipped = $flag; } /** * Returns the time spent running the tests. * * @return float */ public function time() { return $this->time; } /** * Returns whether the entire test was successful or not. * * @return boolean */ public function wasSuccessful() { return empty($this->errors) && empty($this->failures); } /** * Sets the timeout for small tests. * * @param integer $timeout * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.6.0 */ public function setTimeoutForSmallTests($timeout) { if (!is_integer($timeout)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); } $this->timeoutForSmallTests = $timeout; } /** * Sets the timeout for medium tests. * * @param integer $timeout * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.6.0 */ public function setTimeoutForMediumTests($timeout) { if (!is_integer($timeout)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); } $this->timeoutForMediumTests = $timeout; } /** * Sets the timeout for large tests. * * @param integer $timeout * @throws PHPUnit_Framework_Exception * @since Method available since Release 3.6.0 */ public function setTimeoutForLargeTests($timeout) { if (!is_integer($timeout)) { throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); } $this->timeoutForLargeTests = $timeout; } /** * Returns the class hierarchy for a given class. * * @param string $className * @param boolean $asReflectionObjects * @return array */ protected function getHierarchy($className, $asReflectionObjects = false) { if ($asReflectionObjects) { $classes = array(new ReflectionClass($className)); } else { $classes = array($className); } $done = false; while (!$done) { if ($asReflectionObjects) { $class = new ReflectionClass( $classes[count($classes)-1]->getName() ); } else { $class = new ReflectionClass($classes[count($classes)-1]); } $parent = $class->getParentClass(); if ($parent !== false) { if ($asReflectionObjects) { $classes[] = $parent; } else { $classes[] = $parent->getName(); } } else { $done = true; } } return $classes; } } |