You are here

public function FileInputStreamTest::testCharsUnitl in Zircon Profile 8

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

File

vendor/masterminds/html5/test/HTML5/Parser/FileInputStreamTest.php, line 150

Class

FileInputStreamTest

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testCharsUnitl() {
  $s = new FileInputStream(__DIR__ . '/FileInputStreamTest.html');
  $this
    ->assertEquals('', $s
    ->charsUntil('<'));

  // Pointer at '<', moves to ' '
  $this
    ->assertEquals('<!doctype', $s
    ->charsUntil(' ', 20));

  // Pointer at ' ', moves to '>'
  $this
    ->assertEquals(' html', $s
    ->charsUntil('>'));

  // Pointer at '>', moves to '\n'.
  $this
    ->assertEquals('>', $s
    ->charsUntil("\n"));

  // Pointer at '\n', move forward then to the next'\n'.
  $s
    ->next();
  $this
    ->assertEquals('<html lang="en">', $s
    ->charsUntil("\n"));

  // Ony get one of the spaces.
  $this
    ->assertEquals("\n ", $s
    ->charsUntil('<', 2));

  // Get the other space.
  $this
    ->assertEquals(" ", $s
    ->charsUntil('<'));

  // This should scan to the end of the file.
  $text = "<head>\n    <meta charset=\"utf-8\">\n    <title>Test</title>\n  </head>\n  <body>\n    <p>This is a test.</p>\n  </body>\n</html>";
  $this
    ->assertEquals($text, $s
    ->charsUntil("\t"));
}