If you specify the index for the multiple checkbox in both your form and test, then it works. Form:
<input id="department_1" name="departments[0]" type="checkbox" value="1">
<input id="department_2" name="departments[1]" type="checkbox" value="2">
Unit test:
public function testUserCreation()
{
$this->be(User::find(10));
$this->visit('/users/create')
->type('First', 'first_name')
->type('Last', 'last_name')
->type('[email protected]', 'email')
->type('123456', 'password')
->type('123456', 'password_confirmation')
->check('departments[0]')
->press('Submit')
->seePageIs('/users');
}
Using named indexes works as well.
<input name="departments[department_1]" type="checkbox" value="1">
// [...]
$this->check('departments[department_1]');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community