Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 32 lines (31 sloc) 0.97 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?php
/**
* Light wrapper around {@link PHPUnit_Framework_TestSuite}
* which allows to have {@link setUp()} and {@link tearDown()}
* methods which are called just once per suite, not once per
* test method in each suite/case.
*
* @package sapphire
* @subpackage testing
*/
class SapphireTestSuite extends PHPUnit_Framework_TestSuite {
function setUp() {
foreach($this->groups as $group) {
// Assumption: All testcases in the group are the same, as defined in TestRunner->runTests()
$class = get_class($group[0]);
if(class_exists($class) && is_subclass_of($class, 'SapphireTest')) {
eval("$class::set_up_once();");
}
}
}

function tearDown() {
foreach($this->groups as $group) {
$class = get_class($group[0]);
// Assumption: All testcases in the group are the same, as defined in TestRunner->runTests()
if(class_exists($class) && is_subclass_of($class, 'SapphireTest')) {
eval("$class::tear_down_once();");
}
}
}
}
?>
Something went wrong with that request. Please try again.