Testing - get created record

Hi, when testing the Create Page form, I also associate a relationship using a Select.

I can test whether the newly created record is present in the database using assertDatabaseHas, but how would I check whether also the many-to-many relationship was stored?

Can I somehow store the resulting new record in a variable (when calling the
create
action on the CreatePage test), so that I can then retrieve the ID and check the many-to-many table in a separate assertDatabaseHas call?
Was this page helpful?