mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Add test for the multi class classes getter.
This commit is contained in:
parent
f1eadd549b
commit
56422aede2
58
tests/GridFieldAddNewMultiClassTest.php
Normal file
58
tests/GridFieldAddNewMultiClassTest.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Tests for {@link GridFieldAddNewMultiClass}.
|
||||||
|
*/
|
||||||
|
class GridFieldAddNewMultiClassTest extends SapphireTest {
|
||||||
|
|
||||||
|
public function testGetClasses() {
|
||||||
|
$grid = new GridField('TestGridField');
|
||||||
|
$grid->setModelClass('GridFieldAddNewMultiClassTest_A');
|
||||||
|
|
||||||
|
$component = new GridFieldAddNewMultiClass();
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
|
'GridFieldAddNewMultiClassTest_A' => 'A',
|
||||||
|
'GridFieldAddNewMultiClassTest_B' => 'B',
|
||||||
|
'GridFieldAddNewMultiClassTest_C' => 'C'
|
||||||
|
),
|
||||||
|
$component->getClasses($grid),
|
||||||
|
'Subclasses are populated by default and sorted'
|
||||||
|
);
|
||||||
|
|
||||||
|
$component->setClasses(array(
|
||||||
|
'GridFieldAddNewMultiClassTest_B' => 'Custom Title',
|
||||||
|
'GridFieldAddNewMultiClassTest_A'
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
|
'GridFieldAddNewMultiClassTest_B' => 'Custom Title',
|
||||||
|
'GridFieldAddNewMultiClassTest_A' => 'A'
|
||||||
|
),
|
||||||
|
$component->getClasses($grid),
|
||||||
|
'Sorting and custom titles can be specified'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**#@+
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
|
||||||
|
class GridFieldAddNewMultiClassTest_A {
|
||||||
|
public function i18n_singular_name() {
|
||||||
|
$class = get_class($this);
|
||||||
|
return substr($class, strpos($class, '_') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canCreate() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GridFieldAddNewMultiClassTest_B extends GridFieldAddNewMultiClassTest_A {}
|
||||||
|
class GridFieldAddNewMultiClassTest_C extends GridFieldAddNewMultiClassTest_A {}
|
||||||
|
|
||||||
|
/**#@-*/
|
Loading…
Reference in New Issue
Block a user