diff --git a/tests/forms/ListboxFieldTest.php b/tests/forms/ListboxFieldTest.php index 773ae51e3..9851a7267 100644 --- a/tests/forms/ListboxFieldTest.php +++ b/tests/forms/ListboxFieldTest.php @@ -117,19 +117,19 @@ class ListboxFieldTest extends SapphireTest { $field->setValue(array($tag1->ID,$tag2->ID)); $field->saveInto($article); $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false); - $this->assertEquals(array($tag1->ID, $tag2->ID), $article->Tags()->column('ID')); + $this->assertEquals(array($tag1->ID, $tag2->ID), $article->Tags()->sort('ID')->column('ID')); // Remove existing relation $field->setValue(array($tag1->ID)); $field->saveInto($article); $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false); - $this->assertEquals(array($tag1->ID), $article->Tags()->column('ID')); + $this->assertEquals(array($tag1->ID), $article->Tags()->sort('ID')->column('ID')); // Set NULL value $field->setValue(null); $field->saveInto($article); $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false); - $this->assertEquals(array(), $article->Tags()->column('ID')); + $this->assertEquals(array(), $article->Tags()->sort('ID')->column('ID')); } /** @@ -216,4 +216,4 @@ class ListboxFieldTest_Tag extends DataObject implements TestOnly { static $belongs_many_many = array( 'Articles' => 'ListboxFieldTest_Article' ); -} \ No newline at end of file +} diff --git a/tests/forms/gridfield/GridFieldDetailFormTest.php b/tests/forms/gridfield/GridFieldDetailFormTest.php index fca4688f6..b6b5c82d6 100644 --- a/tests/forms/gridfield/GridFieldDetailFormTest.php +++ b/tests/forms/gridfield/GridFieldDetailFormTest.php @@ -8,13 +8,13 @@ class GridFieldDetailFormTest extends FunctionalTest { 'GridFieldDetailFormTest_PeopleGroup', 'GridFieldDetailFormTest_Category', ); - function testAddForm() { $this->logInWithPermission('ADMIN'); $group = DataList::create('GridFieldDetailFormTest_PeopleGroup') - ->filter('Name', 'My Group') - ->First(); + ->filter('Name', 'My Group') + ->sort('Name') + ->First(); $count = $group->People()->Count(); $response = $this->get('GridFieldDetailFormTest_Controller'); @@ -41,16 +41,18 @@ class GridFieldDetailFormTest extends FunctionalTest { $this->assertFalse($response->isError()); $group = DataList::create('GridFieldDetailFormTest_PeopleGroup') - ->filter('Name', 'My Group') - ->First(); - $this->assertEquals($count + 1, $group->People()->Count()); + ->filter('Name', 'My Group') + ->sort('Name') + ->First(); + $this->assertEquals($count + 1, $group->People()->Count()); } function testEditForm() { $this->logInWithPermission('ADMIN'); $group = DataList::create('GridFieldDetailFormTest_PeopleGroup') - ->filter('Name', 'My Group') - ->First(); + ->filter('Name', 'My Group') + ->sort('Name') + ->First(); $firstperson = $group->People()->First(); $this->assertTrue($firstperson->Surname != 'Baggins'); @@ -78,10 +80,11 @@ class GridFieldDetailFormTest extends FunctionalTest { $this->assertFalse($response->isError()); $group = DataList::create('GridFieldDetailFormTest_PeopleGroup') - ->filter('Name', 'My Group') - ->First(); - $firstperson = $group->People()->First(); - $this->assertEquals($firstperson->Surname, 'Baggins'); + ->filter('Name', 'My Group') + ->sort('Name') + ->First(); + $firstperson = $group->People()->First(); + $this->assertEquals($firstperson->Surname, 'Baggins'); } function testNestedEditForm() { @@ -108,7 +111,7 @@ class GridFieldDetailFormTest extends FunctionalTest { $parser = new CSSContentParser($response->getBody()); $personEditLink = $parser->getByXpath('//fieldset[@id="Form_ItemEditForm_People"]//tr[contains(@class, "ss-gridfield-item") and contains(@data-id, "' . $person->ID . '")]//a'); $this->assertEquals( - 'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/' . $person->ID . '/edit', + sprintf('GridFieldDetailFormTest_GroupController/Form/field/testfield/item/%d/ItemEditForm/field/People/item/%d/edit', $group->ID, $person->ID), (string)$personEditLink[0]['href'] ); @@ -118,7 +121,7 @@ class GridFieldDetailFormTest extends FunctionalTest { $parser = new CSSContentParser($response->getBody()); $categoryEditLink = $parser->getByXpath('//fieldset[@id="Form_ItemEditForm_Categories"]//tr[contains(@class, "ss-gridfield-item") and contains(@data-id, "' . $category->ID . '")]//a'); $this->assertEquals( - 'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/' . $category->ID . '/ItemEditForm/field/Categories/item/1/edit', + sprintf('GridFieldDetailFormTest_GroupController/Form/field/testfield/item/%d/ItemEditForm/field/People/item/%d/ItemEditForm/field/Categories/item/%d/edit', $group->ID, $person->ID, $category->ID), (string)$categoryEditLink[0]['href'] ); @@ -202,8 +205,9 @@ class GridFieldDetailFormTest_Controller extends Controller implements TestOnly function Form() { $group = DataList::create('GridFieldDetailFormTest_PeopleGroup') - ->filter('Name', 'My Group') - ->First(); + ->filter('Name', 'My Group') + ->sort('Name') + ->First(); $field = new GridField('testfield', 'testfield', $group->People()); $field->getConfig()->addComponent(new GridFieldToolbarHeader()); @@ -219,7 +223,7 @@ class GridFieldDetailFormTest_GroupController extends Controller implements Test protected $template = 'BlankPage'; function Form() { - $field = new GridField('testfield', 'testfield', DataList::create('GridFieldDetailFormTest_PeopleGroup')); + $field = new GridField('testfield', 'testfield', DataList::create('GridFieldDetailFormTest_PeopleGroup')->sort('Name')); $field->getConfig()->addComponent($gridFieldForm = new GridFieldDetailForm($this, 'Form')); $field->getConfig()->addComponent(new GridFieldToolbarHeader()); $field->getConfig()->addComponent(new GridFieldAddNewButton('toolbar-header-right')); diff --git a/tests/model/ManyManyListTest.php b/tests/model/ManyManyListTest.php index b16f741a7..2dc4700c0 100644 --- a/tests/model/ManyManyListTest.php +++ b/tests/model/ManyManyListTest.php @@ -72,11 +72,11 @@ class ManyManyListTest extends SapphireTest { $team1 = $this->objFromFixture('DataObjectTest_Team', 'team1'); $team2 = $this->objFromFixture('DataObjectTest_Team', 'team2'); $player1->Teams()->setByIdList(array($team1->ID, $team2->ID)); - $this->assertEquals(array($team1->ID, $team2->ID), $player1->Teams()->column()); + $this->assertEquals(array($team1->ID, $team2->ID), $player1->Teams()->sort('Title')->column()); $player1->Teams()->setByIdList(array($team1->ID)); - $this->assertEquals(array($team1->ID), $player1->Teams()->column()); + $this->assertEquals(array($team1->ID), $player1->Teams()->sort('Title')->column()); $player1->Teams()->setByIdList(array($team2->ID)); - $this->assertEquals(array($team2->ID), $player1->Teams()->column()); + $this->assertEquals(array($team2->ID), $player1->Teams()->sort('Title')->column()); } public function testAddingWithMultipleForeignKeys() { @@ -89,7 +89,7 @@ class ManyManyListTest extends SapphireTest { $playersTeam1Team2->add($newPlayer); $this->assertEquals( array($team1->ID, $team2->ID), - $newPlayer->Teams()->column('ID') + $newPlayer->Teams()->sort('Title')->column('ID') ); } @@ -115,4 +115,4 @@ class ManyManyListTest extends SapphireTest { $this->assertEquals(1,$teamsWithoutTheCaptain->count(), 'The ManyManyList should onlu contain one team'); $this->assertEquals($teamTwoID, $teamsWithoutTheCaptain->first()->ID, 'The ManyManyList contains the wrong team'); } -} \ No newline at end of file +}