-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLandmarkRuleTest.php
More file actions
42 lines (33 loc) · 1.55 KB
/
LandmarkRuleTest.php
File metadata and controls
42 lines (33 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace TwigA11y\Tests\Rules\Structure;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use TwigA11y\Rules\Structure\LandmarkRule;
use TwigCsFixer\Test\AbstractRuleTestCase;
#[CoversNothing]
/** @internal */
final class LandmarkRuleTest extends AbstractRuleTestCase
{
/** @param array<null|string> $expectedErrors */
#[DataProvider('provideFixtures')]
public function testRule(string $fixture, array $expectedErrors): void
{
$this->checkRule(new LandmarkRule(), $expectedErrors, $fixture);
}
/** @return iterable<string, array{0:string,1:array<null|string>}> */
public static function provideFixtures(): iterable
{
yield 'has main' => [__DIR__.'/Fixtures/valid/has_main.html.twig', []];
yield 'has role main' => [__DIR__.'/Fixtures/valid/has_role_main.html.twig', []];
yield 'missing main' => [__DIR__.'/Fixtures/invalid/no_main.html.twig', [
'Landmark.Landmark.MissingMain:1:1' => 'Page should include a main landmark',
]];
// Partials/fragments without <body> should NOT trigger the page-level rule
yield 'partial fragment' => [__DIR__.'/Fixtures/valid/partial_component_fragment.html.twig', []];
// Ensure only one error is emitted when the document has </head><body>
yield 'duplicate trigger check' => [__DIR__.'/Fixtures/invalid/duplicate_landmark_trigger.html.twig', [
'Landmark.Landmark.MissingMain:1:1' => 'Page should include a main landmark',
]];
}
}