2013-07-11 04:28:38 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Tests for the {@link GridFieldOrderableRows} component.
|
|
|
|
*/
|
|
|
|
class GridFieldOrderableRowsTest extends SapphireTest {
|
|
|
|
|
|
|
|
protected $usesDatabase = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers GridFieldOrderableRows::getSortTable
|
|
|
|
*/
|
|
|
|
public function testGetSortTable() {
|
|
|
|
$orderable = new GridFieldOrderableRows();
|
|
|
|
|
|
|
|
$parent = new GridFieldOrderableRowsTest_Parent();
|
|
|
|
$parent->write();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'GridFieldOrderableRowsTest_Ordered',
|
2015-10-30 03:06:35 +01:00
|
|
|
$orderable->getSortTable($parent->MyHasMany())
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'GridFieldOrderableRowsTest_Ordered',
|
2015-10-30 03:06:35 +01:00
|
|
|
$orderable->getSortTable($parent->MyHasManySubclass())
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'GridFieldOrderableRowsTest_Ordered',
|
2015-10-30 03:06:35 +01:00
|
|
|
$orderable->getSortTable($parent->MyManyMany())
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
2015-10-30 03:06:35 +01:00
|
|
|
'GridFieldOrderableRowsTest_Parent_MyManyMany',
|
|
|
|
$orderable->setSortField('ManyManySort')->getSortTable($parent->MyManyMany())
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**#@+
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
|
|
|
|
class GridFieldOrderableRowsTest_Parent extends DataObject {
|
|
|
|
|
|
|
|
private static $has_many = array(
|
2015-10-30 03:06:35 +01:00
|
|
|
'MyHasMany' => 'GridFieldOrderableRowsTest_Ordered',
|
|
|
|
'MyHasManySubclass' => 'GridFieldOrderableRowsTest_Subclass'
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
private static $many_many = array(
|
2015-10-30 03:06:35 +01:00
|
|
|
'MyManyMany' => 'GridFieldOrderableRowsTest_Ordered'
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
private static $many_many_extraFields = array(
|
2015-10-30 03:06:35 +01:00
|
|
|
'MyManyMany' => array('ManyManySort' => 'Int')
|
2013-07-11 04:28:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class GridFieldOrderableRowsTest_Ordered extends DataObject {
|
|
|
|
|
|
|
|
private static $db = array(
|
|
|
|
'Sort' => 'Int'
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $has_one = array(
|
|
|
|
'Parent' => 'GridFieldOrderableRowsTest_Parent'
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class GridFieldOrderableRowsTest_Subclass extends GridFieldOrderableRowsTest_Ordered {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**#@-*/
|