/** * Register the service provider. * * @return void */ public function register() { $this->package('form', 'form'); App::bind('Symfony\\Component\\Form\\FormBuilder', function ($app) { $csrf = new DefaultCsrfProvider('change this token'); $translator_builder = new TranslatorBuilder(); $translator_builder->setLocale('nl_NL'); // Uncomment if you want a non-english locale $builder = new Builder(); $builder->setCsrfProvider($csrf); $builder->setTranslator($translator_builder->build()); return $builder->buildFormFactory()->createBuilder(); }); }
private function mockForm() { $builder = new Builder(); $factory = $builder->setCsrfTokenManager($this->csrf->reveal())->setTranslator($this->translator)->buildFormFactory(); $options = array('constraints' => array(new NotBlank())); return $factory->createBuilder()->add('naam', TextType::class, $options)->getForm(); }
public function testFunctionalValidationTranslationTest() { $builder = new Builder(); $environment = $builder->setCsrfTokenManager($this->mockCsrf())->setTranslator($this->mockTranslator())->createTwigEnvironmentBuilder()->prependTwigLoader($this->mockLoader())->build(); $factory = $builder->buildFormFactory(); $options = array('constraints' => array(new NotBlank())); $form = $factory->createBuilder()->add('naam', TextType::class, $options)->getForm(); $form->submit(array('naam' => '')); $this->assertEquals($this->getExpectedTranslatedOutput(), $environment->render('index.html.twig', array('form' => $form->createView()))); }