'Laravel 8 http testing error Failed asserting that two strings are equal
I want to test the endpoint Sign Up (you can consider signup as registration), and at the same time I want to return the response object and redirect the user to sign in endpoint, but when I run the test it gives this error.
• Tests\Unit\ProjectTest > http
Failed asserting that two strings are equal.
at C:\xampp\htdocs\test\tests\Unit\ProjectTest.php:49
45▕ 'Select'=>'Software Engneering',
46▕ 'username'=>'username',
47▕ 'email'=>'email@email'
48▕ ]);
➜ 49▕ $response->assertRedirect('/signin');
50▕ }
1 C:\xampp\htdocs\test\vendor\phpunit\phpunit\phpunit:92
PHPUnit\TextUI\Command::main()
--- Expected
+++ Actual
@@ @@
-'http://localhost/signin'
+'http://localhost'
Tests: 1 failed
Time: 0.19s
And this is the code for the test
public function test_http(){
$response = $this->post('/SignUp',[
'id'=>'4',
'first_name'=>'name',
'middle_name'=>'name',
'family_name'=>'name',
'password'=>'password',
'gender'=>'male',
'work'=>'work',
'Select'=>'Software Engneering',
'username'=>'username',
'email'=>'email@email'
]);
$response->assertRedirect('/signin');
}
I looked for a solution but none of them helped me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|