Answer the question
In order to leave comments, you need to log in
How to test models in laravel?
While I don’t know the tests well
There is an ordinary controller
public function index(Request $request)
{
$users= User::all();
return view('index', compact('users'));
}
Answer the question
In order to leave comments, you need to log in
http tests https://laravel.com/docs/8.x/http-tests
methods assertOk, assertViewHas users, assertSee user full_name. That will cover the entire request.
If the database is not destroyed before the test, then you can get to the collection of users using the getOriginalContent() method on the response
and check the presence in the contains collection using the method
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question