mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Fixed DataObjectTest to use ManyManyList when testing relation manipulations
This commit is contained in:
parent
73c249128b
commit
8d7bfd4ffa
@ -30,9 +30,6 @@ class DataObjectTest extends SapphireTest {
|
|||||||
$obj->write();
|
$obj->write();
|
||||||
$obj->flushCache();
|
$obj->flushCache();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Re-fetch from the database and confirm that the data is sourced from
|
// Re-fetch from the database and confirm that the data is sourced from
|
||||||
// OtherSubclassWithSameField.SubclassDatabaseField
|
// OtherSubclassWithSameField.SubclassDatabaseField
|
||||||
$obj = DataObject::get_by_id('DataObjectTest_Team', $obj->ID);
|
$obj = DataObject::get_by_id('DataObjectTest_Team', $obj->ID);
|
||||||
@ -282,7 +279,10 @@ class DataObjectTest extends SapphireTest {
|
|||||||
// Test adding single DataObject by reference
|
// Test adding single DataObject by reference
|
||||||
$player1->Teams()->add($team1);
|
$player1->Teams()->add($team1);
|
||||||
$player1->flushCache();
|
$player1->flushCache();
|
||||||
$compareTeams = new ManyManyList($team1);
|
|
||||||
|
$compareTeams = new ManyManyList('DataObjectTest_Team','DataObjectTest_Team_Players', 'DataObjectTest_TeamID', 'DataObjectTest_PlayerID');
|
||||||
|
$compareTeams->forForeignID($player1->ID);
|
||||||
|
$compareTeams->byID($team1->ID);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$player1->Teams()->column('ID'),
|
$player1->Teams()->column('ID'),
|
||||||
$compareTeams->column('ID'),
|
$compareTeams->column('ID'),
|
||||||
@ -292,7 +292,9 @@ class DataObjectTest extends SapphireTest {
|
|||||||
// test removing single DataObject by reference
|
// test removing single DataObject by reference
|
||||||
$player1->Teams()->remove($team1);
|
$player1->Teams()->remove($team1);
|
||||||
$player1->flushCache();
|
$player1->flushCache();
|
||||||
$compareTeams = new ManyManyList();
|
$compareTeams = new ManyManyList('DataObjectTest_Team','DataObjectTest_Team_Players', 'DataObjectTest_TeamID', 'DataObjectTest_PlayerID');
|
||||||
|
$compareTeams->forForeignID($player1->ID);
|
||||||
|
$compareTeams->byID($team1->ID);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$player1->Teams()->column('ID'),
|
$player1->Teams()->column('ID'),
|
||||||
$compareTeams->column('ID'),
|
$compareTeams->column('ID'),
|
||||||
@ -302,7 +304,9 @@ class DataObjectTest extends SapphireTest {
|
|||||||
// test adding single DataObject by ID
|
// test adding single DataObject by ID
|
||||||
$player1->Teams()->add($team1->ID);
|
$player1->Teams()->add($team1->ID);
|
||||||
$player1->flushCache();
|
$player1->flushCache();
|
||||||
$compareTeams = new ManyManyList($team1);
|
$compareTeams = new ManyManyList('DataObjectTest_Team','DataObjectTest_Team_Players', 'DataObjectTest_TeamID', 'DataObjectTest_PlayerID');
|
||||||
|
$compareTeams->forForeignID($player1->ID);
|
||||||
|
$compareTeams->byID($team1->ID);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$player1->Teams()->column('ID'),
|
$player1->Teams()->column('ID'),
|
||||||
$compareTeams->column('ID'),
|
$compareTeams->column('ID'),
|
||||||
@ -312,7 +316,9 @@ class DataObjectTest extends SapphireTest {
|
|||||||
// test removing single DataObject by ID
|
// test removing single DataObject by ID
|
||||||
$player1->Teams()->removeByID($team1->ID);
|
$player1->Teams()->removeByID($team1->ID);
|
||||||
$player1->flushCache();
|
$player1->flushCache();
|
||||||
$compareTeams = new ManyManyList();
|
$compareTeams = new ManyManyList('DataObjectTest_Team','DataObjectTest_Team_Players', 'DataObjectTest_TeamID', 'DataObjectTest_PlayerID');
|
||||||
|
$compareTeams->forForeignID($player1->ID);
|
||||||
|
$compareTeams->byID($team1->ID);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$player1->Teams()->column('ID'),
|
$player1->Teams()->column('ID'),
|
||||||
$compareTeams->column('ID'),
|
$compareTeams->column('ID'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user