templateRepository = new InMemoryAppreciationTemplateRepository(); $this->clock = new class implements Clock { public function now(): DateTimeImmutable { return new DateTimeImmutable('2026-03-31 10:00:00'); } }; } #[Test] public function itDeletesTemplate(): void { $template = $this->seedTemplate(); $handler = new DeleteAppreciationTemplateHandler($this->templateRepository); $handler(new DeleteAppreciationTemplateCommand( tenantId: self::TENANT_ID, teacherId: self::TEACHER_ID, templateId: (string) $template->id, )); $found = $this->templateRepository->findById( $template->id, TenantId::fromString(self::TENANT_ID), ); self::assertNull($found); } #[Test] public function itThrowsWhenTemplateNotFound(): void { $handler = new DeleteAppreciationTemplateHandler($this->templateRepository); $this->expectException(AppreciationTemplateNonTrouveeException::class); $handler(new DeleteAppreciationTemplateCommand( tenantId: self::TENANT_ID, teacherId: self::TEACHER_ID, templateId: '550e8400-e29b-41d4-a716-446655440099', )); } #[Test] public function itThrowsWhenTeacherNotOwner(): void { $template = $this->seedTemplate(); $handler = new DeleteAppreciationTemplateHandler($this->templateRepository); $this->expectException(NonProprietaireDuModeleException::class); $handler(new DeleteAppreciationTemplateCommand( tenantId: self::TENANT_ID, teacherId: '550e8400-e29b-41d4-a716-446655440099', templateId: (string) $template->id, )); } private function seedTemplate(): AppreciationTemplate { $template = AppreciationTemplate::creer( tenantId: TenantId::fromString(self::TENANT_ID), teacherId: UserId::fromString(self::TEACHER_ID), title: 'Template test', content: 'Contenu test', category: AppreciationCategory::POSITIVE, now: $this->clock->now(), ); $this->templateRepository->save($template); return $template; } }