I have a link on a page /my/example/page
which links to a laravel route my.route
.
<a href="/my/route/to/external">Link</a>
This route points to this controller method
public function externalLink()
{
return $this->redirect->to('www.externalsite.com');
}
My test is
$this->visit(/my/example/page)
->click('Link')
->assertRedirectedToRoute('my.route');
I constantly get the error
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
I can catch this using @expectedException
but his doesn't help as I am expecting to see a different page (eventually) via a redirect.
I can test the actual redirect using
$response = $this->call('GET', '/my/route/to/external');
$this->assertResponseStatus(302, $response);
But this does not test the functionality of the link on the page. I have also tried
->assertResponseStatus(302);
->seePageIs('www.externalsite.com');
So the full travel path is
http://ift.tt/1VpbUBW --(click url)--> http://ift.tt/213mEWr --(which redirects to)--> www.externalsite.com
How can I test the link of this page redirects to the external site or even hits the middle url?
Aucun commentaire:
Enregistrer un commentaire