mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
bc6b3804b6
commit
508d8d1215
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user