You are here

public function TokenizerTest::testText 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::testText()

File

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

Class

TokenizerTest

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testText() {
  $events = $this
    ->parse('a<br>b');
  $this
    ->assertEquals(4, $events
    ->depth(), "Events: " . print_r($events, true));
  $this
    ->assertEventEquals('text', 'a', $events
    ->get(0));
  $this
    ->assertEventEquals('startTag', 'br', $events
    ->get(1));
  $this
    ->assertEventEquals('text', 'b', $events
    ->get(2));
  $events = $this
    ->parse('<a>Test</a>');
  $this
    ->assertEquals(4, $events
    ->depth(), "Events: " . print_r($events, true));
  $this
    ->assertEventEquals('startTag', 'a', $events
    ->get(0));
  $this
    ->assertEventEquals('text', 'Test', $events
    ->get(1));
  $this
    ->assertEventEquals('endTag', 'a', $events
    ->get(2));
  $events = $this
    ->parse('<p>0</p><p>1</p>');
  $this
    ->assertEquals(7, $events
    ->depth(), "Events: " . print_r($events, true));
  $this
    ->assertEventEquals('startTag', 'p', $events
    ->get(0));
  $this
    ->assertEventEquals('text', '0', $events
    ->get(1));
  $this
    ->assertEventEquals('endTag', 'p', $events
    ->get(2));
  $this
    ->assertEventEquals('startTag', 'p', $events
    ->get(3));
  $this
    ->assertEventEquals('text', '1', $events
    ->get(4));
  $this
    ->assertEventEquals('endTag', 'p', $events
    ->get(5));
  $events = $this
    ->parse('a<![CDATA[test]]>b');
  $this
    ->assertEquals(4, $events
    ->depth(), "Events: " . print_r($events, true));
  $this
    ->assertEventEquals('text', 'a', $events
    ->get(0));
  $this
    ->assertEventEquals('cdata', 'test', $events
    ->get(1));
  $this
    ->assertEventEquals('text', 'b', $events
    ->get(2));
  $events = $this
    ->parse('a<!--test-->b');
  $this
    ->assertEquals(4, $events
    ->depth(), "Events: " . print_r($events, true));
  $this
    ->assertEventEquals('text', 'a', $events
    ->get(0));
  $this
    ->assertEventEquals('comment', 'test', $events
    ->get(1));
  $this
    ->assertEventEquals('text', 'b', $events
    ->get(2));
  $events = $this
    ->parse('a&amp;b');
  $this
    ->assertEquals(2, $events
    ->depth(), "Events: " . print_r($events, true));
  $this
    ->assertEventEquals('text', 'a&b', $events
    ->get(0));
}