Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #29 from patbolo/fix/hardcodedIDs

FIX Do not use hardcoded IDs in tests, as records from fixture might not...
  • Loading branch information...
commit b41da2d7c1a666d9a09f13768cb140e14c8aad5c 2 parents b0e1160 + 0e5426c
@UndefinedOffset 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.