stateManager = $this->app->make(VacationRequestStateManager::class); $this->createCurrentYearPeriod(); } public function testAfterChangingVacationRequestStateNotificationAreSentToUsers(): void { Notification::fake(); $user = User::factory([ "role" => Role::Employee, ])->createQuietly(); $technicalApprover = User::factory([ "role" => Role::TechnicalApprover, ])->createQuietly(); $administrativeApprover = User::factory([ "role" => Role::AdministrativeApprover, ])->createQuietly(); $currentYearPeriod = YearPeriod::current(); /** @var VacationRequest $vacationRequest */ $vacationRequest = VacationRequest::factory([ "type" => VacationType::Vacation->value, "state" => VacationRequestState::Created, "from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "comment" => "Comment for the vacation request.", ]) ->for($user) ->for($currentYearPeriod) ->create(); $this->stateManager->waitForTechnical($vacationRequest); Notification::assertSentTo($technicalApprover, VacationRequestWaitedForTechnicalNotification::class); Notification::assertNotSentTo([$user, $administrativeApprover], VacationRequestWaitedForTechnicalNotification::class); } }