Add tests to ensure that editable form fields allow nullable titles

This commit is contained in:
Robbie Averill 2018-03-23 16:18:32 +13:00
parent e0c4dfd6c6
commit d13bf1e0bc
16 changed files with 199 additions and 2 deletions

View File

@ -18,4 +18,12 @@ class EditableCheckboxGroupFieldTest extends SapphireTest
$checkboxGroup = $this->objFromFixture(EditableCheckboxGroupField::class, 'checkbox-group');
$this->assertSame(UserFormsCheckboxSetField::class, $checkboxGroup->getFormField()->getTemplate());
}
public function testAllowEmptyTitle()
{
/** @var EditableCheckboxGroupField $field */
$field = EditableCheckboxGroupField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableCheckbox;
class EditableCheckboxTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableCheckbox $field */
$field = EditableCheckbox::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -13,4 +13,12 @@ class EditableCountryDropdownFieldTest extends SapphireTest
$this->assertContains('/images/editabledropdown.png', $field->getIcon());
}
public function testAllowEmptyTitle()
{
/** @var EditableCountryDropdownField $field */
$field = EditableCountryDropdownField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableDateField;
class EditableDateFieldTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableDateField $field */
$field = EditableDateField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -36,4 +36,12 @@ class EditableDropdownTest extends SapphireTest
$alternateDropdown->write();
$this->assertEquals($formField->getEmptyString(), '');
}
public function testAllowEmptyTitle()
{
/** @var EditableDropdown $field */
$field = EditableDropdown::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableEmailField;
class EditableEmailFieldTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableEmailField $field */
$field = EditableEmailField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup;
class EditableFieldGroupTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableFieldGroup $field */
$field = EditableFieldGroup::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -64,4 +64,12 @@ class EditableFileFieldTest extends SapphireTest
$formField = $fileField->getFormField();
$this->assertEquals($formField->getValidator()->getAllowedMaxFileSize(), 262144);
}
public function testAllowEmptyTitle()
{
/** @var EditableFileField $field */
$field = EditableFileField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableFormHeading;
class EditableFormHeadingTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableFormHeading $field */
$field = EditableFormHeading::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableFormStep;
class EditableFormStepTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableFormStep $field */
$field = EditableFormStep::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -87,4 +87,12 @@ class EditableLiteralFieldTest extends SapphireTest
'Actual literal field exists in composite field children'
);
}
public function testAllowEmptyTitle()
{
/** @var EditableLiteralField $field */
$field = EditableLiteralField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Security\Group;
use SilverStripe\UserForms\Model\EditableFormField\EditableMemberListField;
class EditableMemberListFieldTest extends SapphireTest
{
protected static $fixture_file = 'EditableMemberListFieldTest.yml';
public function testAllowEmptyTitle()
{
/** @var EditableMemberListField $field */
$field = EditableMemberListField::create();
$field->GroupID = $this->idFromFixture(Group::class, 'a_group');
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -0,0 +1,3 @@
SilverStripe\Security\Group:
a_group:
Title: A security group

View File

@ -0,0 +1,17 @@
<?php
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\EditableFormField\EditableNumericField;
class EditableNumericFieldTest extends SapphireTest
{
public function testAllowEmptyTitle()
{
/** @var EditableNumericField $field */
$field = EditableNumericField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -3,8 +3,6 @@
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\FormField\UserFormsCheckboxSetField;
use SilverStripe\UserForms\Model\EditableFormField\EditableCheckboxGroupField;
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
class EditableRadioFieldTest extends SapphireTest
@ -22,4 +20,12 @@ class EditableRadioFieldTest extends SapphireTest
$radio->getFormField()->getTemplate()
);
}
public function testAllowEmptyTitle()
{
/** @var EditableRadioField $field */
$field = EditableRadioField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}

View File

@ -20,4 +20,12 @@ class EditableTextFieldTest extends SapphireTest
$this->assertInstanceOf(DropdownField::class, $autocompleteField);
$this->assertEquals(['foo' => 'foo'], $autocompleteField->getSource());
}
public function testAllowEmptyTitle()
{
/** @var EditableTextField $field */
$field = EditableTextField::create();
$field->Name = 'EditableFormField_123456';
$this->assertEmpty($field->getFormField()->Title());
}
}