This could be related to caching, can you try php artisan route:clear
Another problem could be in the routes file itself. Can you show us your routes/web.php for the login and signup route?
Hi there !
I'm doing test for signup right now and I have problem. I try to redirect user to route('login') from route('signup').
My validation request
public function signup()
{
return view('auth.signup');
}
public function signupPost(Request $request)
{
$requestTwo = $request->validate([
'username' => 'required|string|min:3|unique:users',
'email' => 'required|string|email|unique:users',
'password' => 'required|min:6|confirmed'
]);
$user = new User();
$user->username = $request->username;
$user->email = $request->email;
$user->password = $request->password;
$user->save();
return redirect()->route('login');
}
my signup Test
public function guest_can_register()
{
$this->expectException(AuthenticationException::class);
$this->withoutMiddleware();
// $this->withoutExceptionHandling();
$user = factory(User::class)->create(
['username' => 'azerty']
);
$userRequests = [
'username' => $user->username,
'email' => $user->email,
'password' => $user->password,
'password_confirmation' => $user->password
];
$response = $this->from(route('signup'))->post(
route('signupPost'),$userRequests
);
$response->assertRedirect(route('login'))
->assertSessionHasNoErrors();
$this->assertDatabaseHas('users', [
'username' => $user->username,
'email' => $user->email,
'password' => $user->password
]);
}
and this is the output of testing
r guest can load signup page → Test code or tested code did not (only) close its own output buffers
✕ guest can register
Tests: 1 failed, 1 risked, 1 passed, 2 pending
Failed asserting that two strings are equal.
at tests/Feature/SignupTest.php:67
63| $response = $this->from(route('signup'))->post(
64| route('signupPost'),$userRequests
65| );
66|
> 67| $response->assertRedirect(route('login'))
68| ->assertSessionHasNoErrors();
69|
70| $this->assertDatabaseHas('users', [
71| 'username' => $user->username,
--- Expected
+++ Actual
@@ @@
-'http://localhost/connexion'
+'http://localhost/inscription'
When I completed inputs manually on the webpage, It's works but not with my test and I don't know what's the problem...
Can you help me please? Thank you by advance :) See you.
Please or to participate in this conversation.