Выводит ошибку
Session missing key: errors
│ Failed asserting that false is true.
class MyUserTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->user = factory(User::class)->make();
}
/** @test */
function name_should_not_be_too_long22()
{
$response = $this->post('/users', [
'name' => 'sdsfaf',
'email' => 'ffffssff@yandex.ru',
'password' => 'secret',
]);
$response->assertSessionHasErrors([
'name' => 'The name may not be greater than 50 characters.'
]);
}
}
class MyUsersController extends Controller
{
public function store(Request $request)
{
$data = $request->validate([
'name' => 'required|max:50',
'email' => 'required|email|max:255',
'password' => 'required',
]);
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}