diff --git a/app/Architecture/Providers/EventServiceProvider.php b/app/Architecture/Providers/EventServiceProvider.php index 5165e75..6741ab1 100644 --- a/app/Architecture/Providers/EventServiceProvider.php +++ b/app/Architecture/Providers/EventServiceProvider.php @@ -18,6 +18,7 @@ use Toby\Domain\Listeners\CreateVacationRequestActivity; use Toby\Domain\Listeners\HandleAcceptedByAdministrativeVacationRequest; use Toby\Domain\Listeners\HandleAcceptedByTechnicalVacationRequest; use Toby\Domain\Listeners\HandleApprovedVacationRequest; +use Toby\Domain\Listeners\HandleCancelledVacationRequest; use Toby\Domain\Listeners\HandleCreatedVacationRequest; use Toby\Domain\Listeners\SendApprovedVacationRequestNotification; use Toby\Domain\Listeners\SendCancelledVacationRequestNotification; @@ -39,5 +40,4 @@ class EventServiceProvider extends ServiceProvider VacationRequestWaitedForTechnical::class => [SendWaitedForTechnicalVacationRequestNotification::class], VacationRequestWaitedForAdministrative::class => [SendWaitedForAdministrativeVacationRequestNotification::class], ]; - -} \ No newline at end of file +} diff --git a/tests/Unit/VacationRequestNotificationTest.php b/tests/Unit/VacationRequestNotificationTest.php index f2b197c..19ca4be 100644 --- a/tests/Unit/VacationRequestNotificationTest.php +++ b/tests/Unit/VacationRequestNotificationTest.php @@ -12,7 +12,7 @@ use Tests\Traits\InteractsWithYearPeriods; use Toby\Domain\Enums\Role; use Toby\Domain\Enums\VacationRequestState; use Toby\Domain\Enums\VacationType; -use Toby\Domain\Notifications\VacationRequestNotification; +use Toby\Domain\Notifications\VacationRequestWaitedForTechnicalNotification; use Toby\Domain\VacationRequestStateManager; use Toby\Eloquent\Models\User; use Toby\Eloquent\Models\VacationRequest; @@ -64,43 +64,7 @@ class VacationRequestNotificationTest extends TestCase $this->stateManager->waitForTechnical($vacationRequest); - Notification::assertSentTo([$user, $technicalApprover, $administrativeApprover], VacationRequestNotification::class); - } - - public function testAfterChangingVacationRequestStateNotificationIsNotSentToAnotherEmployee(): void - { - Notification::fake(); - - $user = User::factory([ - "role" => Role::Employee, - ])->createQuietly(); - $anotherUser = 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([$user, $technicalApprover, $administrativeApprover], VacationRequestNotification::class); - Notification::assertNotSentTo([$anotherUser], VacationRequestNotification::class); + Notification::assertSentTo($technicalApprover, VacationRequestWaitedForTechnicalNotification::class); + Notification::assertNotSentTo([$user, $administrativeApprover], VacationRequestWaitedForTechnicalNotification::class); } }