mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Merge branch '2' into 3.0
This commit is contained in:
commit
be7cae29bf
7
_config.php
Normal file
7
_config.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Ensure compatibility with PHP 7.2 ("object" is a reserved word),
|
||||||
|
// with SilverStripe 3.6 (using Object) and SilverStripe 3.7 (using SS_Object)
|
||||||
|
if (!class_exists('SS_Object')) {
|
||||||
|
class_alias('Object', 'SS_Object');
|
||||||
|
}
|
@ -21,7 +21,10 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "~4.0"
|
"silverstripe/framework": "~4.0"
|
||||||
},
|
},
|
||||||
"extra": {
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^5.7"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
"installer-name": "gridfieldextensions",
|
"installer-name": "gridfieldextensions",
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
"docs/en/_images/editable-rows.png",
|
"docs/en/_images/editable-rows.png",
|
||||||
|
@ -21,7 +21,9 @@ class GridFieldOrderableRowsTest extends SapphireTest
|
|||||||
'GridFieldOrderableRowsTest_Parent',
|
'GridFieldOrderableRowsTest_Parent',
|
||||||
'GridFieldOrderableRowsTest_Ordered',
|
'GridFieldOrderableRowsTest_Ordered',
|
||||||
'GridFieldOrderableRowsTest_Subclass',
|
'GridFieldOrderableRowsTest_Subclass',
|
||||||
);
|
'GridFieldOrderableRowsTest_Unorderable',
|
||||||
|
'GridFieldOrderableRowsTest_OrderableChild',
|
||||||
|
);
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
@ -64,6 +66,35 @@ class GridFieldOrderableRowsTest extends SapphireTest
|
|||||||
$this->assertEquals($desiredOrder, $newOrder);
|
$this->assertEquals($desiredOrder, $newOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
*/
|
*/
|
||||||
@ -128,7 +159,9 @@ class GridFieldOrderableRowsTest_Ordered extends DataObject implements TestOnly
|
|||||||
'Parent' => 'GridFieldOrderableRowsTest_Parent'
|
'Parent' => 'GridFieldOrderableRowsTest_Parent'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many =array(
|
private static $has_many = array(
|
||||||
|
'Children' => 'GridFieldOrderableRowsTest_OrderableChild',
|
||||||
|
);private static $belongs_many_many =array(
|
||||||
'MyManyMany' => 'GridFieldOrderableRowsTest_Parent',
|
'MyManyMany' => 'GridFieldOrderableRowsTest_Parent',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -137,4 +170,21 @@ class GridFieldOrderableRowsTest_Subclass extends GridFieldOrderableRowsTest_Ord
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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