diff --git a/tests/Form/Type/FormSpecificationTypeTest.php b/tests/Form/Type/FormSpecificationTypeTest.php index d64f6bb..3cff5c2 100644 --- a/tests/Form/Type/FormSpecificationTypeTest.php +++ b/tests/Form/Type/FormSpecificationTypeTest.php @@ -55,7 +55,7 @@ protected function getExtensions(): array /** * @covers \Zikula\Bundle\DynamicFormBundle\Entity\AbstractFormSpecification */ - public function testNameFieldOnNew(): void + public function testFormCreation(): void { $formData = new class() extends AbstractFormSpecification { }; @@ -63,6 +63,11 @@ public function testNameFieldOnNew(): void $this->assertTrue($form->has('name')); $this->assertFalse($form->get('name')->isDisabled()); + + $this->assertInstanceOf(TextType::class, $form->get('labels')->getConfig()->getType()->getInnerType()); + $this->assertInstanceOf(TextType::class, $form->get('groups')->getConfig()->getType()->getInnerType()); + $this->assertCount(0, $form->get('labels')); + $this->assertCount(0, $form->get('groups')); } /** diff --git a/tests/Form/Type/FormSpecificationTypeTranslatedTest.php b/tests/Form/Type/FormSpecificationTypeTranslatedTest.php new file mode 100644 index 0000000..8af6154 --- /dev/null +++ b/tests/Form/Type/FormSpecificationTypeTranslatedTest.php @@ -0,0 +1,74 @@ + 'en', 'German' => 'de']; + } + }; + + $dispatcher->addSubscriber(new FormTypeChoiceEventSubscriber($translator)); + $formSpecificationType = new FormSpecificationType($dispatcher, true); + $translationCollectionType = new TranslationCollectionType($localeProvider); + + return [ + new PreloadedExtension([$formSpecificationType, $translationCollectionType], []), + ]; + } + + /** + * @covers \Zikula\Bundle\DynamicFormBundle\Entity\AbstractFormSpecification + */ + public function testFormCreation(): void + { + $formData = new class() extends AbstractFormSpecification { + }; + $form = $this->factory->create(FormSpecificationType::class, $formData); + $this->assertInstanceOf(TranslationCollectionType::class, $form->get('labels')->getConfig()->getType()->getInnerType()); + $this->assertInstanceOf(TranslationCollectionType::class, $form->get('groups')->getConfig()->getType()->getInnerType()); + $this->assertCount(2, $form->get('labels')); + $this->assertCount(2, $form->get('groups')); + $this->assertTrue($form->get('labels')->has('en')); + $this->assertTrue($form->get('labels')->has('de')); + $this->assertTrue($form->get('groups')->has('en')); + $this->assertTrue($form->get('groups')->has('de')); + } +}