hash($password); app(UserRepository::class)->create(new CreateUserDto( email: new EmailAddress($email), passwordHash: $passwordHash, )); $response = $this->postJson('/api/login', [ 'email' => $email, 'password' => $password, ]); $response->assertOk(); $response->assertJsonPath('user.email', $email); $cookie = $response->getCookie( AuthMiddleware::COOKIE_NAME, false, ); $this->assertNotNull($cookie); $this->assertNotNull( app(SessionRepository::class)->findByToken( $cookie->getValue(), ), ); } }