jeudi 20 août 2015

Untick a checkbox during testing in Laravel

Doing something like this:

$this->visit('/path')
    ->check('field')
    ->push('Save');

Will submit a form with the field checkbox ticked regardless of its initial state.

How do I submit the same form with the checkbox un-ticked when it was pre-ticket in the form response? Laravel's crawler doesn't seem to provide a method to do this.

I've tried going through the underlying Symfony\Component\DomCrawler\Form:

$visit = $this->visit('/path');
$form = $visit->getForm('Save');
$form['field'] = 0;

But that triggers the following error:

Input "unique_parcel" cannot take "0" as a value (possible values: 1).

Aucun commentaire:

Enregistrer un commentaire