mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
TEST Cover base table last edited update
This commit is contained in:
parent
fbc7278378
commit
23c0a58e48
@ -12,6 +12,8 @@ class GridFieldOrderableRowsTest extends SapphireTest {
|
|||||||
'GridFieldOrderableRowsTest_Parent',
|
'GridFieldOrderableRowsTest_Parent',
|
||||||
'GridFieldOrderableRowsTest_Ordered',
|
'GridFieldOrderableRowsTest_Ordered',
|
||||||
'GridFieldOrderableRowsTest_Subclass',
|
'GridFieldOrderableRowsTest_Subclass',
|
||||||
|
'GridFieldOrderableRowsTest_Unorderable',
|
||||||
|
'GridFieldOrderableRowsTest_OrderableChild',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testReorderItems() {
|
public function testReorderItems() {
|
||||||
@ -49,6 +51,35 @@ class GridFieldOrderableRowsTest extends SapphireTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSortableChildClass() {
|
||||||
|
$orderable = new GridFieldOrderableRows('Sort');
|
||||||
|
$reflection = new ReflectionMethod($orderable, 'executeReorder');
|
||||||
|
$reflection->setAccessible(true);
|
||||||
|
|
||||||
|
$parent = $this->objFromFixture('GridFieldOrderableRowsTest_Ordered', 'nestedtest');
|
||||||
|
|
||||||
|
$config = new GridFieldConfig_RelationEditor();
|
||||||
|
$config->addComponent($orderable);
|
||||||
|
|
||||||
|
$grid = new GridField(
|
||||||
|
'Children',
|
||||||
|
'Children',
|
||||||
|
$parent->Children(),
|
||||||
|
$config
|
||||||
|
);
|
||||||
|
|
||||||
|
$originalOrder = $parent->Children()->column('ID');
|
||||||
|
$desiredOrder = array_reverse($originalOrder);
|
||||||
|
|
||||||
|
$this->assertNotEquals($originalOrder, $desiredOrder);
|
||||||
|
|
||||||
|
$reflection->invoke($orderable, $grid, $desiredOrder);
|
||||||
|
|
||||||
|
$newOrder = $parent->Children()->column('ID');
|
||||||
|
|
||||||
|
$this->assertEquals($desiredOrder, $newOrder);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers GridFieldOrderableRows::getSortTable
|
* @covers GridFieldOrderableRows::getSortTable
|
||||||
*/
|
*/
|
||||||
@ -112,6 +143,10 @@ class GridFieldOrderableRowsTest_Ordered extends DataObject implements TestOnly
|
|||||||
'Parent' => 'GridFieldOrderableRowsTest_Parent'
|
'Parent' => 'GridFieldOrderableRowsTest_Parent'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $has_many = array(
|
||||||
|
'Children' => 'GridFieldOrderableRowsTest_OrderableChild',
|
||||||
|
);
|
||||||
|
|
||||||
private static $belongs_many_many =array(
|
private static $belongs_many_many =array(
|
||||||
'MyManyMany' => 'GridFieldOrderableRowsTest_Parent',
|
'MyManyMany' => 'GridFieldOrderableRowsTest_Parent',
|
||||||
);
|
);
|
||||||
@ -121,4 +156,21 @@ class GridFieldOrderableRowsTest_Ordered extends DataObject implements TestOnly
|
|||||||
class GridFieldOrderableRowsTest_Subclass extends GridFieldOrderableRowsTest_Ordered implements TestOnly {
|
class GridFieldOrderableRowsTest_Subclass extends GridFieldOrderableRowsTest_Ordered implements TestOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GridFieldOrderableRowsTest_Unorderable extends DataObject implements TestOnly {
|
||||||
|
}
|
||||||
|
|
||||||
|
class GridFieldOrderableRowsTest_OrderableChild extends GridFieldOrderableRowsTest_Unorderable implements TestOnly {
|
||||||
|
|
||||||
|
private static $db = array(
|
||||||
|
'Sort' => 'Int',
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $has_one = array(
|
||||||
|
'Parent' => 'GridFieldOrderableRowsTest_Ordered',
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $default_sort = '"Sort" ASC';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
GridFieldOrderableRowsTest_Ordered:
|
|
||||||
item1:
|
|
||||||
item2:
|
|
||||||
item3:
|
|
||||||
item4:
|
|
||||||
item5:
|
|
||||||
item6:
|
|
||||||
GridFieldOrderableRowsTest_Parent:
|
GridFieldOrderableRowsTest_Parent:
|
||||||
parent:
|
parent:
|
||||||
MyManyMany:
|
MyManyMany:
|
||||||
@ -20,3 +13,27 @@ GridFieldOrderableRowsTest_Parent:
|
|||||||
ManyManySort: 108
|
ManyManySort: 108
|
||||||
- 5: =>GridFieldOrderableRowsTest_Ordered.item6
|
- 5: =>GridFieldOrderableRowsTest_Ordered.item6
|
||||||
ManyManySort: 108
|
ManyManySort: 108
|
||||||
|
GridFieldOrderableRowsTest_OrderableChild:
|
||||||
|
item1:
|
||||||
|
Sort: 1
|
||||||
|
item2:
|
||||||
|
Sort: 2
|
||||||
|
item3:
|
||||||
|
Sort: 3
|
||||||
|
item4:
|
||||||
|
Sort: 4
|
||||||
|
GridFieldOrderableRowsTest_Ordered:
|
||||||
|
item1:
|
||||||
|
Sort: 1
|
||||||
|
item2:
|
||||||
|
Sort: 2
|
||||||
|
item3:
|
||||||
|
Sort: 3
|
||||||
|
item4:
|
||||||
|
Sort: 4
|
||||||
|
item5:
|
||||||
|
Sort: 5
|
||||||
|
item6:
|
||||||
|
Sort: 6
|
||||||
|
nestedtest:
|
||||||
|
Children: =>GridFieldOrderableRowsTest_OrderableChild.item1,=>GridFieldOrderableRowsTest_OrderableChild.item2,=>GridFieldOrderableRowsTest_OrderableChild.item3,=>GridFieldOrderableRowsTest_OrderableChild.item4
|
||||||
|
Loading…
Reference in New Issue
Block a user