packages/requirements/tests/Unit/Config/Markdown/PresentationTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Config\Markdown;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\Attributes\UsesClass;
10use PHPUnit\Framework\TestCase;
11use Requirements\Config\Markdown\Presentation;
12use Requirements\Config\Markdown\Reference;
13
14#[CoversClass(Presentation::class)]
15#[UsesClass(Reference::class)]
16#[Small]
17final class PresentationTest extends TestCase
18{
19 public function testPresentationStartsWithNothingRemembered(): void
20 {
21 $presentation = new Presentation();
22 self::assertSame([], $presentation->links);
23 self::assertSame([], $presentation->badges);
24 self::assertSame([], $presentation->citations);
25 self::assertSame([], $presentation->references);
26 }
27
28 public function testPresentationKeepsWhatAReadRecords(): void
29 {
30 $presentation = new Presentation();
31 $reference = new Reference('REQ-001', 'reference.yaml#req-001', 'definition.md');
32 $presentation->links['SPEC-001']['requirements'] = ['REQ-001' => 'reference.yaml#req-001'];
33 $presentation->badges['SPEC-001']['label'] = ['grammar' => ['url' => 'assets/grammar.svg', 'title' => null]];
34 $presentation->citations['SPEC-001'] = [null, ['url' => 'source.html#a', 'label' => 'Names']];
35 $presentation->references[] = $reference;
36 self::assertSame(['SPEC-001' => ['requirements' => ['REQ-001' => 'reference.yaml#req-001']]], $presentation->links);
37 self::assertSame(['SPEC-001' => ['label' => ['grammar' => ['url' => 'assets/grammar.svg', 'title' => null]]]], $presentation->badges);
38 self::assertSame(['SPEC-001' => [null, ['url' => 'source.html#a', 'label' => 'Names']]], $presentation->citations);
39 self::assertSame([$reference], $presentation->references);
40 }
41}
42