$mglnr, 'password' => $password, ]); return $this; } public function failedNami(int $mglnr = 12345, string $password = 'password'): self { Auth::failed($mglnr, $password); NamiSettings::fake([ 'mglnr' => $mglnr, 'password' => $password, ]); return $this; } public function login(): self { $this->be($user = User::factory()->create()); $this->me = $user; return $this; } public function init(): self { Member::factory()->defaults()->create(); return $this; } public function assertErrors(array $errors, TestResponse $response) { $response->assertSessionHas('errors'); $this->assertInstanceOf(RedirectResponse::class, $response->baseResponse); /** @var RedirectResponse */ $response = $response; $sessionErrors = $response->getSession()->get('errors')->getBag('default'); foreach ($errors as $key => $value) { $this->assertTrue($sessionErrors->has($key), "Cannot find key {$key} in errors '".print_r($sessionErrors, true)); $this->assertEquals($value, $sessionErrors->get($key)[0], "Failed to validate value for session error key {$key}. Actual value: ".print_r($sessionErrors, true)); } return $this; } }