You are here

public function TokenizerTest::testSimpleTags in Zircon Profile 8

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

This tests just simple tags.

File

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

Class

TokenizerTest

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testSimpleTags() {
  $open = array(
    '<foo>' => 'foo',
    '<FOO>' => 'foo',
    '<fOO>' => 'foo',
    '<foo >' => 'foo',
    "<foo\n\n\n\n>" => 'foo',
    '<foo:bar>' => 'foo:bar',
  );
  $this
    ->isAllGood('startTag', 2, $open);
  $selfClose = array(
    '<foo/>' => 'foo',
    '<FOO/>' => 'foo',
    '<foo />' => 'foo',
    "<foo\n\n\n\n/>" => 'foo',
    '<foo:bar/>' => 'foo:bar',
  );
  foreach ($selfClose as $test => $expects) {
    $events = $this
      ->parse($test);
    $this
      ->assertEquals(3, $events
      ->depth(), "Counting events for '{$test}'" . print_r($events, true));
    $this
      ->assertEventEquals('startTag', $expects, $events
      ->get(0));
    $this
      ->assertEventEquals('endTag', $expects, $events
      ->get(1));
  }
  $bad = array(
    '<foo' => 'foo',
    '<foo ' => 'foo',
    '<foo/' => 'foo',
    '<foo /' => 'foo',
  );
  foreach ($bad as $test => $expects) {
    $events = $this
      ->parse($test);
    $this
      ->assertEquals(3, $events
      ->depth(), "Counting events for '{$test}': " . print_r($events, true));
    $this
      ->assertEventError($events
      ->get(0));
    $this
      ->assertEventEquals('startTag', $expects, $events
      ->get(1));
  }
}