Hey. I am trying to create a test for a laravel controller that is not view dependent. I have the following method in the controller class:
public function store(Request $request)
{
$this->validate($request,[
'name'=>'required',
'login'=>'required',
'password'=>'required'
]);
return redirect('usuario/nuevo');
}
And I found the following code to check if the request had any errors:
public function testStore()
{
$response=$this->call('GET','usuario.store');
$this->assertSessionHasErrors();
}
As this test should pass, as I send the request without filling in the field, however, PhpUnit returns the following message:
Session missing key: errors
Failed asserting that false is true.
The only way I can get it to work is to try to "see" the error message on the response page by running the test as follows:
public function testStore()
{
$this->visit('/usuario/nuevo')
->press('Crear')
->see('Whoops');
}
: 1) "" ( ) 2) "", , , .
, , , .