在Laravel 8中进行测试时,会话错误返回null

问题描述

为什么session('errors')为测试返回空值?

规则:

'number' => ['required','integer','min:1','max:66',new BookNumberExists($translation,$book)]

测试:

$this->actingAs($user)
  ->patch(route('books.update',['translation' => $translation,'book' => $book]),[
      'name' => $book->name,'abbr' => $book->abbr,'number' => 0
  ])
  ->assertSessionHasErrors([
      'number' => 'The number must be at least 1.'
  ]);

  // this returns null when I comment out the assert
  dd(session('errors');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)