MINOR: Added tests for many_many_extraFields (from r89013)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89210 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-10-15 22:40:38 +00:00
parent bc6b3804b6
commit 508d8d1215

View File

@ -669,6 +669,29 @@ class DataObjectTest extends SapphireTest {
$this->assertEquals($playerExtraFields, array(
'Position' => 'Varchar(100)'
));
// Iterate through a many-many relationship and confirm that extra fields are included
$newTeam = new DataObjectTest_Team();
$newTeam->Title = "New team";
$newTeam->write();
$newTeamID = $newTeam->ID;
$newPlayer = new DataObjectTest_Player();
$newPlayer->FirstName = "Sam";
$newPlayer->Surname = "Minnee";
$newPlayer->write();
// The idea of Sam as a prop is essentially humourous.
$newTeam->Players()->add($newPlayer, array("Position" => "Prop"));
// Requery and uncache everything
$newTeam->flushCache();
$newTeam = DataObject::get_by_id('DataObjectTest_Team', $newTeamID);
// Check that the Position many_many_extraField is extracted.
$player = $newTeam->Players()->First();
$this->assertEquals('Sam', $player->FirstName);
$this->assertEquals("Prop", $player->Position);
}
/**