mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
6e10acf6cd
closes #17
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Tests the {@see EditableDropdown} class
|
|
*/
|
|
class EditableDropdownTest extends SapphireTest
|
|
{
|
|
|
|
public static $fixture_file = 'userforms/tests/EditableFormFieldTest.yml';
|
|
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
/**
|
|
* Tests that the field sets the empty string if set
|
|
*/
|
|
public function testFormField()
|
|
{
|
|
if (!$dropdown = EditableDropdown::get()->filter('UseEmptyString', true)->first()) {
|
|
$dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown');
|
|
|
|
$dropdown->UseEmptyString = true;
|
|
$dropdown->EmptyString = 'My Default Empty String';
|
|
$dropdown->write();
|
|
}
|
|
|
|
$field = $dropdown->getFormField();
|
|
$this->assertEquals($field->getEmptyString(), 'My Default Empty String');
|
|
|
|
$alternateDropdown = $this->objFromFixture('EditableDropdown', 'department-dropdown');
|
|
$formField = $alternateDropdown->getFormField();
|
|
$this->assertFalse($formField->getHasEmptyDefault());
|
|
|
|
$alternateDropdown->UseEmptyString = true;
|
|
$alternateDropdown->write();
|
|
$this->assertEquals($formField->getEmptyString(), '');
|
|
|
|
}
|
|
|
|
}
|