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);
Thanks you so much for this.
very helpful Fabien