Summer Sale! All accounts are 50% off this week.

liandhas's avatar

Validation Assertion for in:array

it('requires one of the value from an array', function () {

    $this->actingAs(User::first())
        ->livewire(StoreAttribute::class)
        ->set('name', 'Color')
        ->set('type', 'option6')
        ->call('store')
        ->assertHasErrors(['type' => 'in:option1,option2']);
});

I try to assert the following code, but the assertion is unsuccessful.

Component has no [in:option1,option2] errors for [type] attribute.
Failed asserting that an array contains In:option1,option2.
0 likes
3 replies
Nakov's avatar

And in your StoreAttribute Component do you have

protected $rules = [
    'type' => 'in:option1,option2',
];

?

1 like
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Skip the options

        ->assertHasErrors(['type' => 'in']);
1 like

Please or to participate in this conversation.