'input', 'subtype' => 'text', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'text', ], 'default' => [ 'value' => 'testValue', ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A text input element can be generated with a custom value')] public function testGenerateTextInputWithValue() : void { $element = [ 'type' => 'input', 'subtype' => 'text', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'text', ], 'default' => [ 'value' => 'testValue', ], ]; self::assertEquals( '', FormElementGenerator::generate($element, 'manualValue') ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A datetime input element can be generated with custom formatting')] public function testGenerateDateTimeInput() : void { $element = [ 'type' => 'input', 'subtype' => 'datetime', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'datetime', ], 'default' => [ "value" => "2019-02-03 01:23", "format" => "Y-m-d", ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A checkbox element can be generated')] public function testGenerateCheckboxInput() : void { $element = [ 'type' => 'input', 'subtype' => 'checkbox', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'checkbox', ], 'default' => [ 'value' => 'testValue', 'checked' => true, 'content' => 'testContent', ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A checkbox element can be generated with a localized label element')] public function testGenerateCheckboxWithLanguageInput() : void { $element = [ 'type' => 'input', 'subtype' => 'checkbox', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'checkbox', ], 'default' => [ 'value' => 'testValue', 'checked' => false, 'content' => 'testContent', ], ]; self::assertEquals( '', FormElementGenerator::generate($element, null, ['testContent' => 'langContent']) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A radio element can be generated')] public function testGenerateRadioInput() : void { $element = [ 'type' => 'input', 'subtype' => 'radio', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'radio', ], 'default' => [ 'value' => 'testValue', 'checked' => true, 'content' => 'testContent', ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A radio element can be generated with a localized label element')] public function testGenerateRadioWithLanguageInput() : void { $element = [ 'type' => 'input', 'subtype' => 'radio', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', 'type' => 'radio', ], 'default' => [ 'value' => 'testValue', 'checked' => false, 'content' => 'testContent', ], ]; self::assertEquals( '', FormElementGenerator::generate($element, null, ['testContent' => 'langContent']) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A label element can be generated')] public function testGenerateLabel() : void { $element = [ 'type' => 'label', 'attributes' => [ 'for' => 'testId', ], 'default' => [ 'value' => 'testValue', ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A localized label element can be generated')] public function testGenerateWithLanguageLabel() : void { $element = [ 'type' => 'label', 'attributes' => [ 'for' => 'testId', ], 'default' => [ 'value' => 'testValue', ], ]; self::assertEquals( '', FormElementGenerator::generate($element, null, ['testValue' => 'langValue']) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A textarea element can be generated')] public function testGenerateTextarea() : void { $element = [ 'type' => 'textarea', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', ], 'default' => [ 'value' => 'testValue', ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A textarea element can be generated with a custom value')] public function testGenerateWithValueTextarea() : void { $element = [ 'type' => 'textarea', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', ], 'default' => [ 'value' => 'testValue', ], ]; self::assertEquals( '', FormElementGenerator::generate($element, 'manualValue') ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A select element can be generated')] public function testGenerateSelect() : void { $element = [ 'type' => 'select', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', ], 'options' => [ 'option1' => 'value1', 'option2' => 'value2', 'option3' => 'value3', ], 'default' => [ 'value' => 'option2', ], ]; self::assertEquals( '', FormElementGenerator::generate($element) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A localized select element can be generated')] public function testGenerateWithLanguageSelect() : void { $element = [ 'type' => 'select', 'attributes' => [ 'id' => 'testId', 'name' => 'testName', ], 'options' => [ 'option1' => 'value1', 'option2' => 'value2', 'option3' => 'value3', ], 'default' => [ 'value' => 'option2', ], ]; self::assertEquals( '', FormElementGenerator::generate($element, null, ['value2' => 'lang2']) ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A missing or invalid element type generates a INVALID output')] public function testInvalidElementType() : void { self::assertEquals( 'INVALID', FormElementGenerator::generate([]) ); self::assertEquals( 'INVALID', FormElementGenerator::generate(['type' => 'somethingInvalid']) ); } }