Source of file EditableCountryDropdownFieldTest.php
Size: 2,134 Bytes - Last Modified: 2021-12-23T10:35:40+00:00
/var/www/docs.ssmods.com/process/src/tests/php/Model/EditableFormField/EditableCountryDropdownFieldTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php namespace SilverStripe\UserForms\Tests\Model\EditableFormField; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\DropdownField; use SilverStripe\UserForms\Model\EditableFormField\EditableCountryDropdownField; class EditableCountryDropdownFieldTest extends SapphireTest { public function testGetIcon() { $field = new EditableCountryDropdownField; $this->assertStringContainsString('/images/editabledropdown.png', $field->getIcon()); } public function testAllowEmptyTitle() { /** @var EditableCountryDropdownField $field */ $field = EditableCountryDropdownField::create(); $field->Name = 'EditableFormField_123456'; $this->assertEmpty($field->getFormField()->Title()); } public function testCMSFieldsContainsDefaultValue() { /** @var EditableCountryDropdownField $field */ $field = EditableCountryDropdownField::create(); $cmsFields = $field->getCMSFields(); $defaultField = $cmsFields->dataFieldByName('Default'); $this->assertNotNull($defaultField); $this->assertInstanceOf(DropdownField::class, $defaultField); } public function testDefaultValue() { /** @var EditableCountryDropdownField $field */ $field = EditableCountryDropdownField::create(); $field->Default = 'nz'; $this->assertEquals($field->getFormField()->Value(), 'nz'); } public function testEmptyDefaultValue() { /** @var EditableCountryDropdownField $field */ $field = EditableCountryDropdownField::create(); /** @var DropdownField $formField */ $formField = $field->getFormField(); $this->assertFalse($formField->getHasEmptyDefault()); $this->assertEmpty($formField->getEmptyString()); $field->UseEmptyString = true; $field->EmptyString = '--- empty ---'; /** @var DropdownField $formField */ $formField = $field->getFormField(); $this->assertTrue($formField->getHasEmptyDefault()); $this->assertEquals($formField->getEmptyString(), $field->EmptyString); } } |