New in Symfony 2.4: Disabling internal Validation of DomCrawler ChoiceFormFields
The BrowserKit and DomCrawler components simulate the behavior of a real browser. When submitting a form in a browser, it's not possible to (easily at least) choose a non-valid choice in a select box. So, by default, when trying to do so when submitting a form with DomCrawler, you get an exception.
But when writing functional tests, you might want to test the behavior of your application when submitting wrong values on choice form fields. That's even a good idea when testing an HTTP API. As of Symfony 2.4, you can now explicitly disable internal validation of choice field values:
1 2 3 4
$form = $crawler->selectButton('validate')->form(); $form->disableValidation(); $crawler = $client->submit($form, $values);
New in Symfony 2.4: Disabling internal Validation of DomCrawler ChoiceFormFields symfony.com/blog/new-in-symfony-2-4-disabling-internal-validation-of-domcrawler-choiceformfieldsTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.