mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Add a test for GridFieldOrderableRows::getSortTable
This commit is contained in:
parent
dc16c34d6e
commit
4ed382e7a0
77
tests/GridFieldOrderableRowsTest.php
Normal file
77
tests/GridFieldOrderableRowsTest.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?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',
|
||||
$orderable->getSortTable($parent->HasMany())
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'GridFieldOrderableRowsTest_Ordered',
|
||||
$orderable->getSortTable($parent->HasManySubclass())
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'GridFieldOrderableRowsTest_Ordered',
|
||||
$orderable->getSortTable($parent->ManyMany())
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'GridFieldOrderableRowsTest_Parent_ManyMany',
|
||||
$orderable->setSortField('ManyManySort')->getSortTable($parent->ManyMany())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**#@+
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
class GridFieldOrderableRowsTest_Parent extends DataObject {
|
||||
|
||||
private static $has_many = array(
|
||||
'HasMany' => 'GridFieldOrderableRowsTest_Ordered',
|
||||
'HasManySubclass' => 'GridFieldOrderableRowsTest_Subclass'
|
||||
);
|
||||
|
||||
private static $many_many = array(
|
||||
'ManyMany' => 'GridFieldOrderableRowsTest_Ordered'
|
||||
);
|
||||
|
||||
private static $many_many_extraFields = array(
|
||||
'ManyMany' => array('ManyManySort' => 'Int')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
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 {
|
||||
}
|
||||
|
||||
/**#@-*/
|
Loading…
Reference in New Issue
Block a user