收到此错误“会话缺少预期的密钥[错误]。”

时间:2019-07-07 15:09:23

标签: unit-testing laravel-5.8 laravel-testing

我有类似的issue for this issue post

我的控制器正在使用此代码触发错误。

return redirect()->back()->withErrors(['This is a custom message']);//error message

我的单元测试如下。

    $response = $this->from('/projects/project-1')->post('/slides/submit-new', [
        'project_id'    => 1,
        'title'         => 'This is title',
        'submit'        => 'Submit',
    ]);


    $response->assertSessionHasErrors([], null, 'This is a custom message');

Laravel 5.8中的单元测试失败,并出现跟随错误。

Session is missing expected key [error].
Failed asserting that false is true.

0 个答案:

没有答案