I am testing a controller method and I am accessing a route in a test.
Then I would like to make sure that the correct model was returned in the view and was loaded with all of the correct relationships.
I know that I can do this:
$this->assertViewHas("content");
But can how can I verify that the content model that was returned into the view has the correct, for example, category? i.e. how can I get the content model object and then do something like
$this->assertEquals($content->category->name, "category 1");
?
->assertViewHas($key, $value).->assertViewHas('content', $value)but what I want to do is->assertViewHas('content->category', $value)and this returns null (I think because trying to access the View's 'content' attribute returns an Eloquent object and not a Model. I am not exactly sure. Or because the view doesn't have a 'content->category' attribute. But in any case, i haven't been able to get it to do what I want.