mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
e2e32317d6
Also rename ViewableData to ModelData ahead of the template layer lift-and-shift
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Forms\Tests;
|
|
|
|
use SilverStripe\Core\ArrayLib;
|
|
use SilverStripe\ORM\FieldType\DBEnum;
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
class EnumFieldTest extends SapphireTest
|
|
{
|
|
public function testAnyFieldIsPresentInSearchField()
|
|
{
|
|
$values = [
|
|
'Key' => 'Value'
|
|
];
|
|
$enumField = new DBEnum('testField', $values);
|
|
|
|
$searchField = $enumField->scaffoldSearchField();
|
|
|
|
$anyText = "(" . _t('SilverStripe\\ORM\\FieldType\\DBEnum.ANY', 'Any') . ")";
|
|
$this->assertEquals(true, $searchField->getHasEmptyDefault());
|
|
$this->assertEquals($anyText, $searchField->getEmptyString());
|
|
}
|
|
|
|
public function testEnumParsing()
|
|
{
|
|
$enum = new DBEnum(
|
|
'testField',
|
|
"
|
|
,
|
|
0,
|
|
Item1,
|
|
Item2,
|
|
Item 3,
|
|
Item-4,
|
|
item 5
|
|
still 5,
|
|
trailing comma,
|
|
"
|
|
);
|
|
|
|
$this->assertEquals(
|
|
ArrayLib::valuekey(
|
|
[
|
|
'',
|
|
'0',
|
|
'Item1',
|
|
'Item2',
|
|
'Item 3',
|
|
'Item-4',
|
|
'item 5
|
|
still 5',
|
|
'trailing comma'
|
|
]
|
|
),
|
|
$enum->enumValues()
|
|
);
|
|
}
|
|
}
|