mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Added test for has one relation getters in DataObjectTest
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@77313 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b57f60b4ee
commit
5a277c7a2c
@ -154,6 +154,21 @@ class DataObjectTest extends SapphireTest {
|
||||
$this->assertTrue($comment->ParentID == $page->ID);
|
||||
}
|
||||
}
|
||||
|
||||
function testHasOneRelationship() {
|
||||
$team1 = $this->fixture->objFromFixture('DataObjectTest_Team', 'team1');
|
||||
$player1 = $this->fixture->objFromFixture('DataObjectTest_Player', 'player1');
|
||||
|
||||
// Add a captain to team 1
|
||||
$team1->setField('CaptainID', $player1->ID);
|
||||
$team1->write();
|
||||
|
||||
$this->assertEquals($player1->ID, $team1->Captain()->ID, 'The captain exists for team 1');
|
||||
$this->assertEquals($player1->ID, $team1->getComponent('Captain')->ID, 'The captain exists through the component getter');
|
||||
|
||||
$this->assertEquals($team1->Captain()->FirstName, 'Player 1', 'Player 1 is the captain');
|
||||
$this->assertEquals($team1->getComponent('Captain')->FirstName, 'Player 1', 'Player 1 is the captain');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Test removeMany() and addMany() on $many_many relationships
|
||||
@ -577,7 +592,7 @@ class DataObjectTest_Player extends Member implements TestOnly {
|
||||
static $has_one = array(
|
||||
'FavouriteTeam' => 'DataObjectTest_Team',
|
||||
);
|
||||
|
||||
|
||||
static $belongs_many_many = array(
|
||||
'Teams' => 'DataObjectTest_Team'
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user