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
This commit is contained in:
Sam Minnee 2008-08-22 03:33:25 +00:00
parent 8f51649160
commit fb822a0924

View File

@ -70,7 +70,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
* @param $identifier The identifier string, as provided in your fixture file * @param $identifier The identifier string, as provided in your fixture file
*/ */
protected function idFromFixture($className, $identifier) { 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 * @return A map of fixture-identifier => object-id
*/ */
protected function allFixtureIDs($className) { 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 * @param $identifier The identifier string, as provided in your fixture file
*/ */
protected function objFromFixture($className, $identifier) { 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);
} }
/** /**