I have a controller that, after sending email, performs a redirect to the house, for example:
return Redirect::route('home')->with("message", "Ok!");
I am writing tests for it, and I'm not sure how to get phpunit to follow the redirect to check for a success message:
public function testMessageSucceeds() { $crawler = $this->client->request('POST', '/contact', ['email' => ' test@test.com ', 'message' => "lorem ipsum"]); $this->assertResponseStatus(302); $this->assertRedirectedToRoute('home'); $message = $crawler->filter('.success-message');
If I replaced the code on the controller for this, and I delete the first 2 statements, it works
Session::flash('message', 'Ok!'); return $this->makeView('staticPages.home');
But I would like to use Redirect::route . Is there a way to get PHPUnit to follow the redirect?
source share