MINOR Fixed array/string notation in SapphireTest error messages

BUGFIX Using get_by_id() in DataObjectTest to grab deleted pages, to avoid error messages for missing fixtures from SapphireTest

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@81313 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-07-08 02:54:01 +00:00
parent 6c505e5ede
commit 883be66524
2 changed files with 9 additions and 5 deletions

View File

@ -122,11 +122,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
if($match) return $match;
}
$fixtureFiles = Object::get_static(get_class($this), 'fixture_file');
user_error(sprintf(
"Couldn't find object '%s' (class: %s) in files %s",
$identifier,
$className,
implode(',', Object::get_static(get_class($this), 'fixture_file'))
(is_array($fixtureFiles)) ? implode(',', $fixtureFiles) : $fixtureFiles
), E_USER_ERROR);
return false;
@ -168,12 +169,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
$match = $fixture->objFromFixture($className, $identifier);
if($match) return $match;
}
$fixtureFiles = Object::get_static(get_class($this), 'fixture_file');
user_error(sprintf(
"Couldn't find object '%s' (class: %s) in files %s",
$identifier,
$className,
implode(',', Object::get_static(get_class($this), 'fixture_file'))
(is_array($fixtureFiles)) ? implode(',', $fixtureFiles) : $fixtureFiles
), E_USER_ERROR);
return false;

View File

@ -16,24 +16,26 @@ class DataObjectTest extends SapphireTest {
// Test deleting using delete() on the DataObject
// Get the first page
$page = $this->objFromFixture('Page', 'page1');
$pageID = $page->ID;
// Check the page exists before deleting
$this->assertTrue(is_object($page) && $page->exists());
// Delete the page
$page->delete();
// Check that page does not exist after deleting
$page = $this->objFromFixture('Page', 'page1');
$page = DataObject::get_by_id('Page', $pageID);
$this->assertTrue(!$page || !$page->exists());
// Test deleting using DataObject::delete_by_id()
// Get the second page
$page2 = $this->objFromFixture('Page', 'page2');
$page2ID = $page2->ID;
// Check the page exists before deleting
$this->assertTrue(is_object($page2) && $page2->exists());
// Delete the page
DataObject::delete_by_id('Page', $page2->ID);
// Check that page does not exist after deleting
$page2 = $this->objFromFixture('Page', 'page2');
$page2 = DataObject::get_by_id('Page', $page2ID);
$this->assertTrue(!$page2 || !$page2->exists());
}