Here is my test code:
public function testRegistrationFailsIfNameIsEmpty() { $this->flushSession(); $response = $this->call('POST', '/signup', ['fullname' => '']); $this->assertSessionHasErrors('fullname');
When I call this method, it validates the input, and if the validation fails, it redirects me back to /signup to show validation errors. I checked it manually in the browser and it works as expected.
However, when I run the unit test above, the last statement fails, and it believes that I am redirected only to / rather than /signup .
I have no idea why this is being done. If I verify that the redirect has occurred at all, the test passes because the redirect does occur, it just thinks that the redirect will be / instead of /signup .
I turned off all middleware, so I know that this is not something like guest middleware. I logged in when I do not.
EDIT: test results:
There was 1 failure: 1) RegistrationTest::testRegistrationFailsIfNameIsEmpty Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'http://localhost/signup' +'http://localhost'
source share