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

in order of addition.
This commit is contained in:
Robert Curry 2012-04-16 14:30:13 +12:00
parent e99ada4ebd
commit 5686392a67
3 changed files with 8 additions and 7 deletions

View File

@ -60,8 +60,10 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
$parser = new CSSContentParser($response->getBody()); $parser = new CSSContentParser($response->getBody());
$items = $parser->getBySelector('.ss-gridfield .ss-gridfield-items .ss-gridfield-item'); $items = $parser->getBySelector('.ss-gridfield .ss-gridfield-items .ss-gridfield-item');
$this->assertEquals(2, count($items)); $this->assertEquals(2, count($items));
$this->assertEquals($team1->ID, (int)$items[0]['data-id']); $this->assertDOSEquals(array(
$this->assertEquals($team2->ID, (int)$items[1]['data-id']); array('ID' => (int)$items[0]['data-id']),
array('ID' => (int)$items[1]['data-id']),
), new ArrayList(array($team1, $team2)));
} }

View File

@ -46,7 +46,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
$this->setExpectedException('ValidationException'); $this->setExpectedException('ValidationException');
$stateID = 'testGridStateActionField'; $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)); $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request); $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.'); $this->assertEquals(3, $this->list->count(), 'User should\'t be able to delete records without correct permissions.');
@ -55,7 +55,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
public function testDeleteActionWithAdminPermission() { public function testDeleteActionWithAdminPermission() {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$stateID = 'testGridStateActionField'; $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)); $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request); $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.'); $this->assertEquals(2, $this->list->count(), 'User should be able to delete records with ADMIN permission.');
@ -70,7 +70,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
$form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList()); $form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
$stateID = 'testGridStateActionField'; $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)); $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request); $this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request);

View File

@ -83,8 +83,7 @@ class GridFieldDetailFormTest extends FunctionalTest {
->filter('Name', 'My Group') ->filter('Name', 'My Group')
->sort('Name') ->sort('Name')
->First(); ->First();
$firstperson = $group->People()->First(); $this->assertDOSContains(array(array('Surname' => 'Baggins')), $group->People());
$this->assertEquals($firstperson->Surname, 'Baggins');
} }
function testNestedEditForm() { function testNestedEditForm() {