File: W3CReferenceTest.php

package info (click to toggle)
symfony 8.0.0~rc1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,876 kB
  • sloc: php: 1,510,009; xml: 2,415; javascript: 979; sh: 586; makefile: 244; pascal: 70
file content (53 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (4)
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
44
45
46
47
48
49
50
51
52
53
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HtmlSanitizer\Tests\Reference;

use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HtmlSanitizer\Reference\W3CReference;

/**
 * Check that the W3CReference class is up to date with the standard resources.
 */
class W3CReferenceTest extends TestCase
{
    #[Group('network')]
    public function testElements()
    {
        $referenceElements = array_values(array_merge(array_keys(W3CReference::HEAD_ELEMENTS), array_keys(W3CReference::BODY_ELEMENTS)));
        sort($referenceElements);

        $this->assertSame(
            $this->getResourceData(__DIR__.'/../Fixtures/baseline-element-allow-list.json'),
            $referenceElements
        );
    }

    #[Group('network')]
    public function testAttributes()
    {
        $this->assertSame(
            $this->getResourceData(__DIR__.'/../Fixtures/baseline-attribute-allow-list.json'),
            array_keys(W3CReference::ATTRIBUTES)
        );
    }

    private function getResourceData(string $resource): array
    {
        return json_decode(
            file_get_contents($resource),
            true,
            512,
            \JSON_THROW_ON_ERROR
        );
    }
}