2017-08-16 03:59:41 +02:00
|
|
|
<?php
|
|
|
|
|
2017-08-22 02:15:22 +02:00
|
|
|
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
|
|
|
|
|
|
|
|
use SilverStripe\Core\Config\Config;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Forms\DropdownField;
|
|
|
|
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
|
|
|
|
|
2017-08-16 03:59:41 +02:00
|
|
|
class EditableTextFieldTest extends SapphireTest
|
|
|
|
{
|
|
|
|
public function testGetCmsFields()
|
|
|
|
{
|
2017-08-22 02:15:22 +02:00
|
|
|
Config::modify()->set(EditableTextField::class, 'autocomplete_options', ['foo' => 'foo']);
|
2017-08-16 03:59:41 +02:00
|
|
|
|
|
|
|
$field = new EditableTextField;
|
|
|
|
$result = $field->getCMSFields();
|
|
|
|
|
|
|
|
$autocompleteField = $result->fieldByName('Root.Main.Autocomplete');
|
2017-08-22 02:15:22 +02:00
|
|
|
$this->assertInstanceOf(DropdownField::class, $autocompleteField);
|
|
|
|
$this->assertEquals(['foo' => 'foo'], $autocompleteField->getSource());
|
2017-08-16 03:59:41 +02:00
|
|
|
}
|
2018-03-23 04:18:32 +01:00
|
|
|
|
|
|
|
public function testAllowEmptyTitle()
|
|
|
|
{
|
|
|
|
/** @var EditableTextField $field */
|
|
|
|
$field = EditableTextField::create();
|
|
|
|
$field->Name = 'EditableFormField_123456';
|
2018-03-23 04:23:51 +01:00
|
|
|
$field->Rows = 1;
|
|
|
|
$this->assertEmpty($field->getFormField()->Title());
|
|
|
|
|
|
|
|
$field->Rows = 3;
|
2018-03-23 04:18:32 +01:00
|
|
|
$this->assertEmpty($field->getFormField()->Title());
|
|
|
|
}
|
2017-08-16 03:59:41 +02:00
|
|
|
}
|