2012-05-28 08:31:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Inject SilverStripe 'setUpOnce' and 'tearDownOnce' unittest extension methods into phpunit
|
|
|
|
// This is already in later SilverStripe 2.4 versions, but having it here extends compatibility to older versions
|
|
|
|
|
|
|
|
class SilverStripeListener implements PHPUnit_Framework_TestListener {
|
|
|
|
|
|
|
|
protected function isValidClass($name) {
|
|
|
|
return (class_exists($name) && is_subclass_of($name, 'SapphireTest'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
|
|
|
$name = $suite->getName();
|
|
|
|
if(!$this->isValidClass($name)) return;
|
|
|
|
|
|
|
|
$class = new $name();
|
|
|
|
$class->setUpOnce();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
|
|
|
$name = $suite->getName();
|
|
|
|
if(!$this->isValidClass($name)) return;
|
|
|
|
|
|
|
|
$class = new $name();
|
|
|
|
$class->tearDownOnce();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function startTest(PHPUnit_Framework_Test $test) {
|
|
|
|
}
|
2012-12-08 12:20:20 +01:00
|
|
|
|
2012-05-28 08:31:48 +02:00
|
|
|
public function endTest(PHPUnit_Framework_Test $test, $time) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
|
|
|
}
|
2012-12-08 12:20:20 +01:00
|
|
|
|
2012-05-28 08:31:48 +02:00
|
|
|
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
|
|
|
}
|
|
|
|
}
|