-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLangAttributeRuleTest.php
More file actions
43 lines (36 loc) · 1.29 KB
/
LangAttributeRuleTest.php
File metadata and controls
43 lines (36 loc) · 1.29 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
43
<?php
declare(strict_types=1);
namespace TwigA11y\Tests\Rules\Structure;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use TwigA11y\Rules\Structure\LangAttributeRule;
use TwigCsFixer\Test\AbstractRuleTestCase;
#[CoversNothing]
/** @internal */
final class LangAttributeRuleTest extends AbstractRuleTestCase
{
/**
* @param array<null|string> $expectedErrors
*/
#[DataProvider('provideFixtures')]
public function testRule(string $fixture, array $expectedErrors): void
{
$this->checkRule(new LangAttributeRule(), $expectedErrors, $fixture);
}
/**
* @return iterable<string, array{0:string,1:array<null|string>}>
*/
public static function provideFixtures(): iterable
{
yield 'html with lang' => [
__DIR__.'/Fixtures/valid/html_with_lang.html.twig',
[],
];
yield 'html without lang' => [
__DIR__.'/Fixtures/invalid/html_no_lang.html.twig',
['LangAttribute.LangAttribute.MissingLang:2:1' => 'The <html> element should have a lang attribute.'],
];
// Partial fragments (no <html>) should not trigger the rule
yield 'partial fragment no html' => [__DIR__.'/Fixtures/valid/partial_no_html.html.twig', []];
}
}