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 itCreatesTemplate(): void { $handler = new CreateAppreciationTemplateHandler($this->templateRepository, $this->clock); $template = $handler(new CreateAppreciationTemplateCommand( tenantId: self::TENANT_ID, teacherId: self::TEACHER_ID, title: 'Très bon travail', content: 'Très bon travail, continuez ainsi !', category: 'positive', )); self::assertSame('Très bon travail', $template->title); self::assertSame('Très bon travail, continuez ainsi !', $template->content); self::assertSame(AppreciationCategory::POSITIVE, $template->category); self::assertSame(0, $template->usageCount); } #[Test] public function itPersistsTemplate(): void { $handler = new CreateAppreciationTemplateHandler($this->templateRepository, $this->clock); $template = $handler(new CreateAppreciationTemplateCommand( tenantId: self::TENANT_ID, teacherId: self::TEACHER_ID, title: 'Test', content: 'Contenu test', category: null, )); $found = $this->templateRepository->findById( $template->id, TenantId::fromString(self::TENANT_ID), ); self::assertNotNull($found); self::assertSame('Test', $found->title); self::assertNull($found->category); } #[Test] public function itCreatesTemplateWithNullCategory(): void { $handler = new CreateAppreciationTemplateHandler($this->templateRepository, $this->clock); $template = $handler(new CreateAppreciationTemplateCommand( tenantId: self::TENANT_ID, teacherId: self::TEACHER_ID, title: 'Sans catégorie', content: 'Contenu', category: null, )); self::assertNull($template->category); } }