Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX: Fixes #7071. Change gridfield tests to not assume ids are always

in order of addition.
  • Loading branch information...
commit 5686392a6707b1a3d54094da44e998465f79a186 1 parent e99ada4
@robert-h-curry robert-h-curry authored
View
6 tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php
@@ -60,8 +60,10 @@ function testAdd() {
$parser = new CSSContentParser($response->getBody());
$items = $parser->getBySelector('.ss-gridfield .ss-gridfield-items .ss-gridfield-item');
$this->assertEquals(2, count($items));
- $this->assertEquals($team1->ID, (int)$items[0]['data-id']);
- $this->assertEquals($team2->ID, (int)$items[1]['data-id']);
+ $this->assertDOSEquals(array(
+ array('ID' => (int)$items[0]['data-id']),
+ array('ID' => (int)$items[1]['data-id']),
+ ), new ArrayList(array($team1, $team2)));
}
View
6 tests/forms/gridfield/GridFieldDeleteActionTest.php
@@ -46,7 +46,7 @@ public function testDeleteActionWithoutCorrectPermission() {
$this->setExpectedException('ValidationException');
$stateID = 'testGridStateActionField';
- Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>1)));
+ Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>$this->idFromFixture('GridFieldAction_Delete_Team', 'team1'))));
$request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request);
$this->assertEquals(3, $this->list->count(), 'User should\'t be able to delete records without correct permissions.');
@@ -55,7 +55,7 @@ public function testDeleteActionWithoutCorrectPermission() {
public function testDeleteActionWithAdminPermission() {
$this->logInWithPermission('ADMIN');
$stateID = 'testGridStateActionField';
- Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>1)));
+ Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>$this->idFromFixture('GridFieldAction_Delete_Team', 'team1'))));
$request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request);
$this->assertEquals(2, $this->list->count(), 'User should be able to delete records with ADMIN permission.');
@@ -70,7 +70,7 @@ public function testDeleteActionRemoveRelation() {
$form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
$stateID = 'testGridStateActionField';
- Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>1)));
+ Session::set($stateID, array('grid'=>'', 'actionName'=>'deleterecord','args'=>array('RecordID'=>$this->idFromFixture('GridFieldAction_Delete_Team', 'team1'))));
$request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request);
View
3  tests/forms/gridfield/GridFieldDetailFormTest.php
@@ -83,8 +83,7 @@ function testEditForm() {
->filter('Name', 'My Group')
->sort('Name')
->First();
- $firstperson = $group->People()->First();
- $this->assertEquals($firstperson->Surname, 'Baggins');
+ $this->assertDOSContains(array(array('Surname' => 'Baggins')), $group->People());
}
function testNestedEditForm() {
Please sign in to comment.
Something went wrong with that request. Please try again.