Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX Do not use hardcoded IDs in tests, as records from fixture might …

…not start at 1
  • Loading branch information...
commit 0e5426c0d7777748eab1e56d60434453e9ac76b1 1 parent b0e1160
@patbolo patbolo authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 tests/forms/GridFieldSortableRowsTest.php
View
14 tests/forms/GridFieldSortableRowsTest.php
@@ -27,21 +27,27 @@ public function setUp() {
public function testSortActionWithoutCorrectPermission() {
if(Member::currentUser()) { Member::currentUser()->logOut(); }
$this->setExpectedException('ValidationException');
+ $team1 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team1');
+ $team2 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team2');
+ $team3 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team3');
$stateID = 'testGridStateActionField';
Session::set($stateID, array('grid'=>'', 'actionName'=>'saveGridRowSort', 'args'=>array('GridFieldSortableRows'=>array('sortableToggle'=>true))));
- $request = new SS_HTTPRequest('POST', 'url', array('ItemIDs'=>'1,3,2'), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
+ $request = new SS_HTTPRequest('POST', 'url', array('ItemIDs'=>"$team1->ID, $team3->ID, $team2->ID"), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request);
- $this->assertEquals(3, $this->list->last()->ID, 'User should\'t be able to sort records without correct permissions.');
+ $this->assertEquals($team3->ID, $this->list->last()->ID, 'User should\'t be able to sort records without correct permissions.');
}
public function testSortActionWithAdminPermission() {
+ $team1 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team1');
+ $team2 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team2');
+ $team3 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team3');
$this->logInWithPermission('ADMIN');
$stateID = 'testGridStateActionField';
Session::set($stateID, array('grid'=>'', 'actionName'=>'saveGridRowSort', 'args'=>array('GridFieldSortableRows'=>array('sortableToggle'=>true))));
- $request = new SS_HTTPRequest('POST', 'url', array('ItemIDs'=>'1,3,2'), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
+ $request = new SS_HTTPRequest('POST', 'url', array('ItemIDs'=>"$team1->ID, $team3->ID, $team2->ID"), array('action_gridFieldAlterAction?StateID='.$stateID=>true));
$this->gridField->gridFieldAlterAction(array('StateID'=>$stateID), $this->form, $request);
- $this->assertEquals(2, $this->list->last()->ID, 'User should be able to sort records with ADMIN permission.');
+ $this->assertEquals($team2->ID, $this->list->last()->ID, 'User should be able to sort records with ADMIN permission.');
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.