I have exact same problem with you, but haven't figured out how to solve this...
Dec 7, 2015
14
Level 6
Session missing 'errors' key in PHPUnit
I can't get the $this->assertSessionHasErrors(); assertion to work.
// The only trait I'm using is DatabaseTransactions
$this->visit('/signup');
$this->submitForm('Create my account', [
'name' => '',
'email' => 'pedro',
'cellphone' => 1698149,
'password' => 123,
'password_confirmation' => 123
]);
$this->seePageIs('/signup');
$this->assertSessionHasErrors(); // this fails
If I $this->dump() the page it shows all the errors messages when the validation fails. It also works correctly in the browser. But when running phpunit all I get is:
Session missing key: errors
Failed asserting that false is true.
I also tried dumping $this->app['session.store'] in my test:
#attributes: array:4 [
"_token" => "2hGrgYb0manQcPBpwi60BFozLnBBMAx0hYJVfEH3"
"_previous" => array:1 [
"url" => "http://localhost/signup"
]
"flash" => array:2 [
"old" => []
"new" => []
]
"_sf2_meta" => array:3 [
"u" => 1449505334
"c" => 1449505334
"l" => "0"
]
]
This is the code where the form posts to in my routes.php:
// …
if ($validator->fails())
{
return redirect('/signup')
->withInput()
->withErrors($validator);
}
// …
I'm using 5.1 fresh installed yesterday.
Please or to participate in this conversation.