mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Proof of reorder bug
This commit is contained in:
parent
423a0d006e
commit
66c09cd60d
@ -6,12 +6,44 @@ class GridFieldOrderableRowsTest extends SapphireTest {
|
||||
|
||||
protected $usesDatabase = true;
|
||||
|
||||
protected static $fixture_file = 'GridFieldOrderableRowsTest.yml';
|
||||
|
||||
protected $extraDataObjects = array(
|
||||
'GridFieldOrderableRowsTest_Parent',
|
||||
'GridFieldOrderableRowsTest_Ordered',
|
||||
'GridFieldOrderableRowsTest_Subclass',
|
||||
);
|
||||
|
||||
public function testReorderItems() {
|
||||
$orderable = new GridFieldOrderableRows('ManyManySort');
|
||||
$reflection = new ReflectionMethod($orderable, 'executeReorder');
|
||||
$reflection->setAccessible(true);
|
||||
|
||||
$parent = $this->objFromFixture('GridFieldOrderableRowsTest_Parent', 'parent');
|
||||
|
||||
$config = new GridFieldConfig_RelationEditor();
|
||||
$config->addComponent($orderable);
|
||||
|
||||
$grid = new GridField(
|
||||
'MyManyMany',
|
||||
'My Many Many',
|
||||
$parent->MyManyMany()->sort('ManyManySort'),
|
||||
$config
|
||||
);
|
||||
|
||||
$originalOrder = $parent->MyManyMany()->sort('ManyManySort')->column('ID');
|
||||
$desiredOrder = array_reverse($originalOrder);
|
||||
|
||||
$this->assertNotEquals($originalOrder, $desiredOrder);
|
||||
|
||||
$reflection->invoke($orderable, $grid, $desiredOrder);
|
||||
|
||||
$newOrder = $parent->MyManyMany()->sort('ManyManySort')->column('ID');
|
||||
|
||||
$this->assertEquals($desiredOrder, $newOrder);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers GridFieldOrderableRows::getSortTable
|
||||
*/
|
||||
|
22
tests/GridFieldOrderableRowsTest.yml
Normal file
22
tests/GridFieldOrderableRowsTest.yml
Normal file
@ -0,0 +1,22 @@
|
||||
GridFieldOrderableRowsTest_Ordered:
|
||||
item1:
|
||||
item2:
|
||||
item3:
|
||||
item4:
|
||||
item5:
|
||||
item6:
|
||||
GridFieldOrderableRowsTest_Parent:
|
||||
parent:
|
||||
MyManyMany:
|
||||
- 0: =>GridFieldOrderableRowsTest_Ordered.item1
|
||||
ManyManySort: 1
|
||||
- 1: =>GridFieldOrderableRowsTest_Ordered.item2
|
||||
ManyManySort: 1
|
||||
- 2: =>GridFieldOrderableRowsTest_Ordered.item3
|
||||
ManyManySort: 2
|
||||
- 3: =>GridFieldOrderableRowsTest_Ordered.item4
|
||||
ManyManySort: 2
|
||||
- 4: =>GridFieldOrderableRowsTest_Ordered.item5
|
||||
ManyManySort: 108
|
||||
- 5: =>GridFieldOrderableRowsTest_Ordered.item6
|
||||
ManyManySort: 108
|
Loading…
Reference in New Issue
Block a user