*/ public static function chapters(): iterable { yield 'overview' => [ 'storyline/chapters/overview.html.twig', 'Sir Aldren was one of the five heroes', 'Kyuss leaking out', ]; yield 'prologue' => [ 'storyline/chapters/prologue-the-long-road.html.twig', 'The Crooked Goose', 'Tell them the blood is no longer enough', ]; yield 'session 1' => [ 'storyline/chapters/session-1-outside-blood.html.twig', 'Are you Thorns?', 'The Hearth & Hound', ]; } #[DataProvider('chapters')] public function testChapterPartialRenders(string $template, string $needle1, string $needle2): void { self::bootKernel(); /** @var Environment $twig */ $twig = self::getContainer()->get('twig'); $html = $twig->render($template); self::assertStringContainsString($needle1, $html); self::assertStringContainsString($needle2, $html); } public function testEveryRegisteredChapterHasATemplateFile(): void { $ref = new \ReflectionClass(StorylineController::class); /** @var array $chapters */ $chapters = $ref->getConstant('CHAPTERS'); self::assertNotEmpty($chapters); foreach ($chapters as $slug => $chapter) { $path = \dirname(__DIR__, 2).'/templates/'.$chapter['template']; self::assertFileExists($path, sprintf('Chapter "%s" points at a missing template.', $slug)); } } }