lundi 1 août 2016

PhpUnit testing, how to check a checkbox if there are multiple checkboxes with same name in a form

I am testing a form. In the form, there are some checkboxes which are with the same name as there are multiple checkboxes to select from.

So my check boxes are like this:

<div class="col-sm-10">
    <div class="checkbox">
        <input id="department_1" name="departments[]" type="checkbox" value="1">
        <label for="department_1">Sales</label>
    </div>
                                            <div class="checkbox">
        <input id="department_2" name="departments[]" type="checkbox" value="2">
        <label for="department_2">Marketing</label>
    </div>
                                            <div class="checkbox">
        <input id="department_3" name="departments[]" type="checkbox" value="3">
        <label for="department_3">Tech Help</label>
    </div>
</div>

My testing code is like this:

public function testUserCreation()
    {
        $this->be(User::find(10));

        $this->visit('/users/create')
            ->type('First', 'first_name')
            ->type('Last', 'last_name')
            ->type('test@esample.com', 'email')
            ->type('123456', 'password')
            ->type('123456', 'password_confirmation')
            ->check('departments')
            ->press('Submit')
            ->seePageIs('/users');
    }

When I am trying to check if throws error:

InvalidArgumentException: Nothing matched the filter [permissions] CSS query provided for



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aplMcV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire