From 848faf2a6b5c542f9546d22d492a62e31ae97f6f Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 4 Oct 2010 04:31:58 +0000 Subject: [PATCH] MINOR tests can now require default records on classes (from r101025) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@111566 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/SapphireTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index ba5727d0f..5f9ae8ef1 100755 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -40,6 +40,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase { protected static $is_running_test = false; + /** + * By default, setUp() does not require default records. Pass + * class names in here, and the require/augment default records + * function will be called on them. + */ + protected $requireDefaultRecordsFrom = array(); + /** * A list of extensions that can't be applied during the execution of this run. If they are @@ -128,6 +135,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase { singleton('DataObject')->flushCache(); self::empty_temp_db(); + + foreach($this->requireDefaultRecordsFrom as $className) { + $instance = singleton($className); + if (method_exists($instance, 'requireDefaultRecords')) $instance->requireDefaultRecords(); + if (method_exists($instance, 'augmentDefaultRecords')) $instance->augmentDefaultRecords(); + } if($fixtureFile) { $fixtureFiles = (is_array($fixtureFile)) ? $fixtureFile : array($fixtureFile);