You are here

public function TokenizerTest::testComment in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/test/HTML5/Parser/TokenizerTest.php \Masterminds\HTML5\Tests\Parser\TokenizerTest::testComment()

File

vendor/masterminds/html5/test/HTML5/Parser/TokenizerTest.php, line 194

Class

TokenizerTest

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testComment() {
  $good = array(
    '<!--easy-->' => 'easy',
    '<!-- 1 > 0 -->' => ' 1 > 0 ',
    '<!-- --$i -->' => ' --$i ',
    '<!----$i-->' => '--$i',
    '<!-- 1 > 0 -->' => ' 1 > 0 ',
    "<!--\nHello World.\na-->" => "\nHello World.\na",
    '<!-- <!-- -->' => ' <!-- ',
  );
  foreach ($good as $test => $expected) {
    $events = $this
      ->parse($test);
    $this
      ->assertEventEquals('comment', $expected, $events
      ->get(0));
  }
  $fail = array(
    '<!-->' => '',
    '<!--Hello' => 'Hello',
    "<!--\0Hello" => UTF8Utils::FFFD . 'Hello',
    '<!--' => '',
  );
  foreach ($fail as $test => $expected) {
    $events = $this
      ->parse($test);
    $this
      ->assertEquals(3, $events
      ->depth());
    $this
      ->assertEventError($events
      ->get(0));
    $this
      ->assertEventEquals('comment', $expected, $events
      ->get(1));
  }
}