mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-08 10:41:25 +02:00
46 lines
850 B
PHP
46 lines
850 B
PHP
<?php
|
|
/**
|
|
* @package framework
|
|
* @subpackage tests
|
|
*/
|
|
class EnumFieldTest extends SapphireTest {
|
|
public function testAnyFieldIsPresentInSearchField() {
|
|
$values = array (
|
|
'Key' => 'Value'
|
|
);
|
|
$enumField = new Enum('testField', $values);
|
|
|
|
$searchField = $enumField->scaffoldSearchField();
|
|
|
|
$anyText = "(" . _t('Enum.ANY', 'Any') . ")";
|
|
$this->assertEquals(true, $searchField->getHasEmptyDefault());
|
|
$this->assertEquals($anyText, $searchField->getEmptyString());
|
|
}
|
|
|
|
public function testEnumParsing() {
|
|
$enum = new Enum('testField', "
|
|
,
|
|
0,
|
|
Item1,
|
|
Item2,
|
|
Item 3,
|
|
Item-4,
|
|
item 5
|
|
still 5,
|
|
trailing comma,
|
|
");
|
|
|
|
$this->assertEquals(ArrayLib::valuekey(array(
|
|
'',
|
|
'0',
|
|
'Item1',
|
|
'Item2',
|
|
'Item 3',
|
|
'Item-4',
|
|
'item 5
|
|
still 5',
|
|
'trailing comma'
|
|
)), $enum->enumValues());
|
|
}
|
|
}
|