2010-10-19 05:43:01 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Necessary to call setUpOnce() and tearDownOnce() on {@link SapphireTest}
|
|
|
|
* classes. This feature doesn't exist in PHPUnit in the same way
|
|
|
|
* (setUpBeforeClass() and tearDownAfterClass() are just called statically).
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2010-10-19 05:43:01 +02:00
|
|
|
* @see http://www.phpunit.de/manual/3.5/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2010-10-19 05:43:01 +02:00
|
|
|
* @subpackage testing
|
|
|
|
*/
|
|
|
|
class SS_TestListener implements PHPUnit_Framework_TestListener {
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2010-10-19 05:43:01 +02:00
|
|
|
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {}
|
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {}
|
2010-10-19 05:43:01 +02:00
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {}
|
2010-10-19 05:43:01 +02:00
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {}
|
2010-10-19 05:43:01 +02:00
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
public function startTest(PHPUnit_Framework_Test $test) {}
|
2010-10-19 05:43:01 +02:00
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
public function endTest(PHPUnit_Framework_Test $test, $time) {}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2010-10-19 05:43:01 +02:00
|
|
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
|
|
|
$name = $suite->getName();
|
|
|
|
if(!$this->isValidClass($name)) return;
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2010-10-19 05:43:01 +02:00
|
|
|
$this->class = new $name();
|
|
|
|
$this->class->setUpOnce();
|
2012-12-08 12:20:20 +01:00
|
|
|
}
|
2010-10-19 05:43:01 +02:00
|
|
|
|
|
|
|
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
|
|
|
$name = $suite->getName();
|
|
|
|
if(!$this->isValidClass($name)) return;
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2010-10-19 05:43:01 +02:00
|
|
|
$this->class->tearDownOnce();
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2014-03-30 08:37:54 +02:00
|
|
|
/**
|
|
|
|
* Risky test.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
* @param Exception $e
|
|
|
|
* @param float $time
|
|
|
|
* @since Method available since Release 3.8.0
|
|
|
|
*/
|
|
|
|
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
|
|
|
// Stub out to support PHPUnit 3.8
|
|
|
|
}
|
2014-02-04 00:32:58 +01:00
|
|
|
|
2010-10-19 05:43:01 +02:00
|
|
|
/**
|
|
|
|
* @param String Classname
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
protected function isValidClass($name) {
|
|
|
|
return (class_exists($name) && is_subclass_of($name, 'SapphireTest'));
|
|
|
|
}
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|