You are here

public function StringInputStreamTest::testCarriageReturn in Zircon Profile 8

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

File

vendor/masterminds/html5/test/HTML5/Parser/StringInputStreamTest.php, line 174

Class

StringInputStreamTest

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testCarriageReturn() {

  // Replace NULL with Unicode replacement.
  $stream = new StringInputStream("\0\0\0");
  $this
    ->assertEquals("���", $stream
    ->remainingChars(), 'Null character should be replaced by U+FFFD');
  $this
    ->assertEquals(3, count($stream->errors), 'Null character should set parse error: ' . print_r($stream->errors, true));

  // Remove CR when next to LF.
  $stream = new StringInputStream("\r\n");
  $this
    ->assertEquals("\n", $stream
    ->remainingChars(), 'CRLF should be replaced by LF');

  // Convert CR to LF when on its own.
  $stream = new StringInputStream("\r");
  $this
    ->assertEquals("\n", $stream
    ->remainingChars(), 'CR should be replaced by LF');
}