Permalink
Browse files

Merge pull request #330 from robert-h-curry/7071-postgresql-gridfield…

…-test-failures

BUGFIX: Fixes #7071. Change gridfield tests to not assume ids are always in order of addition.
  • Loading branch information...
2 parents c62b8e6 + 5686392 commit 311bfba6e227f68dec8372d05d1b3a1f9f5cdfac @halkyon halkyon committed Apr 16, 2012
@@ -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)));
}
@@ -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);
@@ -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() {

0 comments on commit 311bfba

Please sign in to comment.