CharacterReferenceTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @file
  4. * Test the Scanner. This requires the InputStream tests are all good.
  5. */
  6. namespace Masterminds\HTML5\Tests\Parser;
  7. use Masterminds\HTML5\Parser\CharacterReference;
  8. class CharacterReferenceTest extends \Masterminds\HTML5\Tests\TestCase
  9. {
  10. public function testLookupName()
  11. {
  12. $this->assertEquals('&', CharacterReference::lookupName('amp'));
  13. $this->assertEquals('<', CharacterReference::lookupName('lt'));
  14. $this->assertEquals('>', CharacterReference::lookupName('gt'));
  15. $this->assertEquals('"', CharacterReference::lookupName('quot'));
  16. $this->assertEquals('∌', CharacterReference::lookupName('NotReverseElement'));
  17. $this->assertNull(CharacterReference::lookupName('StinkyCheese'));
  18. }
  19. public function testLookupHex()
  20. {
  21. $this->assertEquals('<', CharacterReference::lookupHex('3c'));
  22. $this->assertEquals('<', CharacterReference::lookupHex('003c'));
  23. $this->assertEquals('&', CharacterReference::lookupHex('26'));
  24. $this->assertEquals('}', CharacterReference::lookupHex('7d'));
  25. $this->assertEquals('Σ', CharacterReference::lookupHex('3A3'));
  26. $this->assertEquals('Σ', CharacterReference::lookupHex('03A3'));
  27. $this->assertEquals('Σ', CharacterReference::lookupHex('3a3'));
  28. $this->assertEquals('Σ', CharacterReference::lookupHex('03a3'));
  29. }
  30. public function testLookupDecimal()
  31. {
  32. $this->assertEquals('&', CharacterReference::lookupDecimal(38));
  33. $this->assertEquals('&', CharacterReference::lookupDecimal('38'));
  34. $this->assertEquals('<', CharacterReference::lookupDecimal(60));
  35. $this->assertEquals('Σ', CharacterReference::lookupDecimal(931));
  36. $this->assertEquals('Σ', CharacterReference::lookupDecimal('0931'));
  37. }
  38. }