mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixes #7071. Change gridfield tests to not assume ids are always
in order of addition.
This commit is contained in:
parent
e99ada4ebd
commit
5686392a67
@ -60,8 +60,10 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
|
||||
$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 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
$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 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
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 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
||||
$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 @@ class GridFieldDetailFormTest extends FunctionalTest {
|
||||
->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() {
|
||||
|
Loading…
Reference in New Issue
Block a user