silverstripe-framework/dev/SapphireTestSuite.php
Ingo Schommer 228b976ce1 ENHANCEMENT Adding SapphireTest::set_up_once() and SapphireTest::tear_down_once() for better test performance with state that just needs to be initialized once per test case (not per test method). Added new SapphireTestSuite to support this through PHPUnit.
ENHANCEMENT Using set_up_once() in TranslatableTest and TranslatableSearchFormTest for better test run performance

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@74941 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-04-22 03:22:09 +00:00

32 lines
970 B
PHP

<?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();");
}
}
}
}
?>