Level 55
@davina you test and validation works as expected. You checks every array item in otherSettings, but you do not checks that this array contains something.
If this array should contains at least 1 item - extend your validation
$request->validate([
'otherSettings' => 'required|array',
'otherSettings.*.key' => 'required|string',
'otherSettings.*.value' => 'required|string'
]);
or just pass empty array in request
->post('/settings/other-settings/edit', [
'otherSettings' => [
[] // this one is array item and will be validated by using otherSettings.*
]
])
And the last one - session will contains error with actual indexes instead of *, so, check assertions should looks like
->assertSessionHasErrors([
'otherSettings.0.key',
'otherSettings.0.value'
]);
1 like