New in Symfony 2.4: Disabling internal Validation of DomCrawler ChoiceFormFields
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
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);
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.