diff --git a/tests/Form/CollectionJsTypeTest.php b/tests/Form/CollectionJsTypeTest.php index 10ae012..7df6708 100644 --- a/tests/Form/CollectionJsTypeTest.php +++ b/tests/Form/CollectionJsTypeTest.php @@ -2,8 +2,10 @@ namespace Tienvx\UX\CollectionJs\Tests\Form; +use Symfony\Component\Form\Exception\InvalidConfigurationException; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormView; use Symfony\Component\Form\Test\TypeTestCase; use Tienvx\UX\CollectionJs\Form\CollectionJsType; @@ -52,4 +54,28 @@ public function testCustomOptions() $this->assertTrue($view->vars['call_post_add_on_init']); $this->assertSame('__test__', $view->vars['prototype_name']); } + + public function testDontAllowAdd() + { + $form = $this->factory + ->create(static::TESTED_TYPE, null, [ + 'entry_type' => TextType::class, + 'allow_add' => false, + ]) + ; + + $view = $form->createView(); + $this->assertInstanceOf(FormView::class, $view->vars['prototype']); + } + + public function testDisablePrototype() + { + $this->expectExceptionObject(new InvalidConfigurationException(sprintf('You must enable prototype for form type %s.', static::TESTED_TYPE))); + $this->factory + ->create(static::TESTED_TYPE, null, [ + 'entry_type' => TextType::class, + 'prototype' => false, + ]) + ; + } }