DreiAugenFrosch's avatar

Test (temporary) signed routes with PHPUnit

Hey guys!

I have a temporary signed route to change the email of an user. Now I want to test this route with PHPUnit. But when I try to get the route, I get an "403 Error" (of course).

Is there any smart way to solve this, or do I have to create a new signed route manually and use this for my get request?

Thanks for your help :)

0 likes
3 replies
janosk's avatar

Hi! If you are trying to test another aspect of that route and want to have a signed in user to pass the auth part, then just make up a regular signed in user (or use create if you want to persist it) before your get to the request line.

$this->actingAs(factory(User::class)->make());

Don't forget to import User (use App\User;) at the top, or replace User::class with 'App\User'.

DreiAugenFrosch's avatar

Sorry I didn't mean with Auth locked pages, but URLs created with the URL::temporarySignedRoute method.

Please or to participate in this conversation.