ssquare's avatar

Test if the following validation is passed, and there is no errors on these field

Here, is my sample code:

public function test_hero_section_validation_on_disabled_case()
{
    $this->signIn();
    $attributes =  Service::factory()->raw();
    $attributes['title'] = '';
    $attributes['hero_section'] = 'disabled';
    $attributes['hero_title'] = '';
    $attributes['hero_heading'] = '';
    $attributes['hero_description'] = '';
    $this->post($this->endPoint,$attributes)
        ->assertSessionHasNoErrors(['hero_title','hero_heading','hero_description']);
}

I want to test the above case, if hero_section is disabled, then it should not throw errors on 'hero_title','hero_heading','hero_description' any of these fields.

The above code is currently failing, because of the empty title, but it should have passed, because I am only expecting it to failed if there is any errors on one of those mentioned fields or isn't there any way to test like these and only way to test this case is by providing valid input for other field and only supplying the invalid input value fo the fields I want to check?

0 likes
1 reply
kevinbui's avatar

Can you share your validation rules and returned errors?

Please or to participate in this conversation.