mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 13:19:11 +02:00
ENHANCEMENT: added SapphireTest:: boolean to flag tests that should be skipped from the TestRunner
This commit is contained in:
parent
60ea09bb42
commit
e740bf8a65
@ -57,6 +57,9 @@ class FunctionalTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
// Skip calling FunctionalTest directly.
|
||||||
|
if(get_class($this) == "FunctionalTest") self::$skip_test = true;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->mainSession = new TestSession();
|
$this->mainSession = new TestSession();
|
||||||
|
|
||||||
|
@ -19,6 +19,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
*/
|
*/
|
||||||
static $fixture_file = null;
|
static $fixture_file = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether to include this test in the TestRunner or to skip this.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static $skip_test = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Boolean If set to TRUE, this will force a test database to be generated
|
* @var Boolean If set to TRUE, this will force a test database to be generated
|
||||||
* in {@link setUp()}. Note that this flag is overruled by the presence of a
|
* in {@link setUp()}. Note that this flag is overruled by the presence of a
|
||||||
@ -94,6 +101,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
*/
|
*/
|
||||||
private $extensionsToReapply = array(), $extensionsToRemove = array();
|
private $extensionsToReapply = array(), $extensionsToRemove = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if unit tests are currently run (via {@link TestRunner}).
|
* Determines if unit tests are currently run (via {@link TestRunner}).
|
||||||
* This is used as a cheap replacement for fully mockable state
|
* This is used as a cheap replacement for fully mockable state
|
||||||
@ -113,6 +121,18 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
protected $fixtures;
|
protected $fixtures;
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
// We cannot run the tests on this abstract class.
|
||||||
|
if(get_class($this) == "SapphireTest") self::$skip_test = true;
|
||||||
|
|
||||||
|
// Ensure we are to run this test case
|
||||||
|
if(self::$skip_test) {
|
||||||
|
$this->markTestSkipped(sprintf(
|
||||||
|
'Skipping %s ', get_class($this)
|
||||||
|
));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Mark test as being run
|
// Mark test as being run
|
||||||
$this->originalIsRunningTest = self::$is_running_test;
|
$this->originalIsRunningTest = self::$is_running_test;
|
||||||
self::$is_running_test = true;
|
self::$is_running_test = true;
|
||||||
|
@ -234,11 +234,15 @@ class TestRunner extends Controller {
|
|||||||
self::use_test_manifest();
|
self::use_test_manifest();
|
||||||
$classNames = array();
|
$classNames = array();
|
||||||
$moduleNames = explode(',', $request->param('ModuleName'));
|
$moduleNames = explode(',', $request->param('ModuleName'));
|
||||||
|
|
||||||
foreach($moduleNames as $moduleName) {
|
foreach($moduleNames as $moduleName) {
|
||||||
$classesForModule = ClassInfo::classes_for_folder($moduleName);
|
$classesForModule = ClassInfo::classes_for_folder($moduleName);
|
||||||
if($classesForModule) foreach($classesForModule as $class) {
|
|
||||||
if(class_exists($class) && is_subclass_of($class, 'SapphireTest')) {
|
if($classesForModule) {
|
||||||
$classNames[] = $class;
|
foreach($classesForModule as $className) {
|
||||||
|
if(class_exists($className) && is_subclass_of($className, 'SapphireTest')) {
|
||||||
|
$classNames[] = $className;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user