mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
d52db0ba34
# Conflicts: # .travis.yml # admin/css/ie7.css # admin/css/ie7.css.map # admin/css/ie8.css.map # admin/css/screen.css # admin/css/screen.css.map # admin/javascript/LeftAndMain.js # admin/scss/_style.scss # admin/scss/_uitheme.scss # control/HTTPRequest.php # core/Object.php # css/AssetUploadField.css # css/AssetUploadField.css.map # css/ConfirmedPasswordField.css.map # css/Form.css.map # css/GridField.css.map # css/TreeDropdownField.css.map # css/UploadField.css # css/UploadField.css.map # css/debug.css.map # dev/Debug.php # docs/en/00_Getting_Started/00_Server_Requirements.md # docs/en/02_Developer_Guides/06_Testing/00_Unit_Testing.md # docs/en/02_Developer_Guides/06_Testing/index.md # docs/en/02_Developer_Guides/14_Files/02_Images.md # docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md # filesystem/File.php # filesystem/Folder.php # filesystem/GD.php # filesystem/Upload.php # forms/ToggleField.php # forms/Validator.php # javascript/lang/en_GB.js # javascript/lang/fr.js # javascript/lang/src/en.js # javascript/lang/src/fr.js # model/Image.php # model/UnsavedRelationList.php # model/Versioned.php # model/connect/MySQLDatabase.php # model/fieldtypes/DBField.php # model/fieldtypes/Enum.php # scss/AssetUploadField.scss # scss/UploadField.scss # templates/email/ChangePasswordEmail.ss # templates/forms/DropdownField.ss # tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php # tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php # tests/forms/EnumFieldTest.php # tests/security/MemberTest.php # tests/security/MemberTest.yml # tests/security/SecurityTest.php
49 lines
897 B
PHP
49 lines
897 B
PHP
<?php
|
|
|
|
use SilverStripe\Model\FieldType\DBEnum;
|
|
|
|
/**
|
|
* @package framework
|
|
* @subpackage tests
|
|
*/
|
|
class EnumFieldTest extends SapphireTest {
|
|
public function testAnyFieldIsPresentInSearchField() {
|
|
$values = array (
|
|
'Key' => 'Value'
|
|
);
|
|
$enumField = new DBEnum('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 DBEnum('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());
|
|
}
|
|
}
|