I am working with some unit testing and i have difficult with one kind of assertions
$this->assertRedirectedTo
Here is my very basic example controller code
// example.com/form
public function postForm()
{
$data = "my data";
$this->mylogic($data);
}
private function mylogic($data){
// operations with $data ... after some logics
return redirect()
->route('Gracias')
->send();
}
And this is my very basic example of my unit testing
public function REDRIRECT_TEST()
{
$this->call('POST','form'); // it works
$this->assertRedirectedTo('gracias'); // it fails
}
and i get this error
Failed asserting that Illuminate\Http\Response Object (...) is an instance of class "Illuminate\Http\RedirectResponse".
This error happen when i use redirect inside another method
private function mylogic($data){
return redirect()
->route('Gracias')
->send();
}
Any idea how to deal with assertRedirectedTo
where the redirect()
is inside another method?
Thanks.
Aucun commentaire:
Enregistrer un commentaire