From 6c505e5ede39c5e374c70dd21017dcbf4ebf351b Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 8 Jul 2009 02:36:05 +0000 Subject: [PATCH] MINOR Moving user_error() invocations for missing fixtures from YamlFixture into SapphireTest - we shouldn't error out of a single fixture, as the object in question might be contained in another fixture on the same test git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@81310 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/YamlFixture.php | 13 ++----------- dev/SapphireTest.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/model/YamlFixture.php b/core/model/YamlFixture.php index 144e6ce34..4d7bbd381 100644 --- a/core/model/YamlFixture.php +++ b/core/model/YamlFixture.php @@ -99,12 +99,7 @@ class YamlFixture extends Object { if(isset($this->fixtureDictionary[$className][$identifier])) { return $this->fixtureDictionary[$className][$identifier]; } else { - user_error(sprintf( - "Couldn't find object #%d (%s) in file %s", - $identifier, - $className, - $this->fixtureFile - ), E_USER_ERROR); + return false; } } @@ -118,11 +113,7 @@ class YamlFixture extends Object { if(isset($this->fixtureDictionary[$className])) { return $this->fixtureDictionary[$className]; } else { - user_error(sprintf( - "Couldn't find objects of type %s in file %s", - $className, - $this->fixtureFile - ), E_USER_ERROR); + return false; } } diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 12a33210e..12aa61769 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -122,6 +122,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase { if($match) return $match; } + user_error(sprintf( + "Couldn't find object '%s' (class: %s) in files %s", + $identifier, + $className, + implode(',', Object::get_static(get_class($this), 'fixture_file')) + ), E_USER_ERROR); + return false; } @@ -162,6 +169,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase { if($match) return $match; } + user_error(sprintf( + "Couldn't find object '%s' (class: %s) in files %s", + $identifier, + $className, + implode(',', Object::get_static(get_class($this), 'fixture_file')) + ), E_USER_ERROR); + return false; }