From fb822a0924852319de580c2ea5f465edd55fb937 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 22 Aug 2008 03:33:25 +0000 Subject: [PATCH] Better error message if you have forgotten to set fixture_file git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@61410 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/SapphireTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 03f7967b8..f3488de49 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -70,7 +70,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase { * @param $identifier The identifier string, as provided in your fixture file */ protected function idFromFixture($className, $identifier) { - return $this->fixture->idFromFixture($className, $identifier); + if($this->fixture) return $this->fixture->idFromFixture($className, $identifier); + else user_error("You've called \$this->objFromFixture() but you haven't specified static \$fixture_file.\n" . + "Ensure that static \"\$fixture_file = 'module/tests/fixturefile.yml';\" is specified in your " .get_class($this). " class.", E_USER_WARNING); } /** @@ -78,7 +80,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase { * @return A map of fixture-identifier => object-id */ protected function allFixtureIDs($className) { - return $this->fixture->allFixtureIDs($className); + if($this->fixture) return $this->fixture->allFixtureIDs($className); + else user_error("You've called \$this->objFromFixture() but you haven't specified static \$fixture_file.\n" . + "Ensure that static \"\$fixture_file = 'module/tests/fixturefile.yml';\" is specified in your " .get_class($this). " class.", E_USER_WARNING); } /** @@ -87,7 +91,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase { * @param $identifier The identifier string, as provided in your fixture file */ protected function objFromFixture($className, $identifier) { - return $this->fixture->objFromFixture($className, $identifier); + if($this->fixture) return $this->fixture->objFromFixture($className, $identifier); + else user_error("You've called \$this->objFromFixture() but you haven't specified static \$fixture_file.\n" . + "Ensure that static \"\$fixture_file = 'module/tests/fixturefile.yml';\" is specified in your " .get_class($this). " class.", E_USER_WARNING); } /**