The party reaches Brackenford two hours after Eamon met Aldren: the Thorn beekeepers, the Vale family and Edric's death, the council hiding Eamon, the collection cart, and the first word of blood. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Storyline;
|
|
|
|
use App\Controller\StorylineController;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
use Twig\Environment;
|
|
|
|
/**
|
|
* Renders every storyline chapter partial on its own (no HTTP, no DB) so a
|
|
* broken variable, filter or path() call in the hand-written content fails
|
|
* loudly instead of only at request time.
|
|
*/
|
|
class ChapterTemplatesTest extends KernelTestCase
|
|
{
|
|
/**
|
|
* @return iterable<string, array{string, string, string}>
|
|
*/
|
|
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<string, array{template: string}> $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));
|
|
}
|
|
}
|
|
}
|