Laravel 5.7. I have a test like this:
/** @test */
public function do_nothing_test()
{
$user = factory(User::class)->states('app')->make();
$this->actingAs($user, 'api');
$response = $this->postJson('some_endpoint');
}
which calls an endpoint in a controller that tries to get the logged in user:
public function useless_endpoint()
{
$id = auth()->user()->id;
}
The value of $id
is null
. How can I get the test to work so that the user's details are available to the controller?
Aucun commentaire:
Enregistrer un commentaire