File: CharacterReferenceTest.php

package info (click to toggle)
php-masterminds-html5 2.7.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 736 kB
  • sloc: php: 9,565; makefile: 19
file content (44 lines) | stat: -rw-r--r-- 1,824 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
<?php
/**
 * @file
 * Test the Scanner. This requires the InputStream tests are all good.
 */

namespace Masterminds\HTML5\Tests\Parser;

use Masterminds\HTML5\Parser\CharacterReference;

class CharacterReferenceTest extends \Masterminds\HTML5\Tests\TestCase
{
    public function testLookupName()
    {
        $this->assertEquals('&', CharacterReference::lookupName('amp'));
        $this->assertEquals('<', CharacterReference::lookupName('lt'));
        $this->assertEquals('>', CharacterReference::lookupName('gt'));
        $this->assertEquals('"', CharacterReference::lookupName('quot'));
        $this->assertEquals('∌', CharacterReference::lookupName('NotReverseElement'));

        $this->assertNull(CharacterReference::lookupName('StinkyCheese'));
    }

    public function testLookupHex()
    {
        $this->assertEquals('<', CharacterReference::lookupHex('3c'));
        $this->assertEquals('<', CharacterReference::lookupHex('003c'));
        $this->assertEquals('&', CharacterReference::lookupHex('26'));
        $this->assertEquals('}', CharacterReference::lookupHex('7d'));
        $this->assertEquals('Σ', CharacterReference::lookupHex('3A3'));
        $this->assertEquals('Σ', CharacterReference::lookupHex('03A3'));
        $this->assertEquals('Σ', CharacterReference::lookupHex('3a3'));
        $this->assertEquals('Σ', CharacterReference::lookupHex('03a3'));
    }

    public function testLookupDecimal()
    {
        $this->assertEquals('&', CharacterReference::lookupDecimal(38));
        $this->assertEquals('&', CharacterReference::lookupDecimal('38'));
        $this->assertEquals('<', CharacterReference::lookupDecimal(60));
        $this->assertEquals('Σ', CharacterReference::lookupDecimal(931));
        $this->assertEquals('Σ', CharacterReference::lookupDecimal('0931'));
    }
}