vendredi 7 août 2020

Test to assert that a select input has specific options in it

Assuming I have a model called Dogs. I want to ensure that when a user visits the home page, they can select one of the dogs from a select input. How would I test this in Laravel? here's what I have so far.

    public function a_user_can_select_a_dog()
    {
        $this->withoutExceptionHandling();

        $dogs = App\Dog::all();

        $names = $dogs->map(function ($dog) {
            return $dog->name;
        });

        $response = $this->get(route('home'))->assertSee($names);
    }

ultimately what goes into the assertSee is what I am missing. Or perhaps assertSee() isn't the correct method to use here. I want to make sure that when the user goes to the home page there is a select input there with the 5 dog names that were created by the factory.

Aucun commentaire:

Enregistrer un commentaire