Source of file TextCheckboxGroupFieldTest.php
Size: 1,521 Bytes - Last Modified: 2021-12-24T06:44:48+00:00
/var/www/docs.ssmods.com/process/src/tests/Forms/TextCheckboxGroupFieldTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | <?php namespace DNADesign\Elemental\Tests\Forms; use DNADesign\Elemental\Forms\TextCheckboxGroupField; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CompositeField; use SilverStripe\Forms\TextField; class TextCheckboxGroupFieldTest extends SapphireTest { /** * @var TextCheckboxGroupField */ protected $field; protected function setUp(): void { parent::setUp(); $this->field = new TextCheckboxGroupField('Title'); } public function testFieldIsAssignedFirstFieldsTitleInConstructor() { $this->assertSame('Title', $this->field->Title()); $this->assertSame('Title', $this->field->getChildren()->first()->Title()); } public function testFieldReturnsCompositeFieldTemplateOnReadonlyTransformation() { $this->assertSame( TextCheckboxGroupField::class, $this->field->getTemplates()[0], 'Uses a custom template by default' ); $readonly = $this->field->performReadonlyTransformation(); $this->assertSame( CompositeField::class, $readonly->getTemplate(), 'Uses CompositeField template for readonly' ); } public function testRemovedFieldsCanDoReadonlyTransformation() { $this->field->removeByName('Title'); $readonly = $this->field->performReadonlyTransformation(); $this->assertInstanceOf(TextCheckboxGroupField::class, $readonly); } } |