service = new UserChecker(); } public function testThrowDisabledException() { $user = new User(); $user->setDisabled(false); //An user that is not disabled should not throw an exception $this->service->checkPostAuth($user); //An disabled user must throw an exception $user->setDisabled(true); $this->expectException(DisabledException::class); $this->service->checkPostAuth($user); } }