markTestSkipped('Test calls deprecated code'); } } public function testInvalidHTMLSaving() { $value = new HTML4Value(); $invalid = [ '

Enclosed Value

' => '

Enclosed Value

', '' => '', '

' => '

', '' => '', '/bodu>/body>' => '/bodu>/body>' ]; foreach ($invalid as $input => $expected) { $value->setContent($input); $this->assertEquals($expected, $value->getContent(), 'Invalid HTML can be saved'); } } public function testUtf8Saving() { $value = new HTML4Value(); $value->setContent('

ö ß ā い 家

'); $this->assertEquals('

ö ß ā い 家

', $value->getContent()); } public function testInvalidHTMLTagNames() { $value = new HTML4Value(); $invalid = [ '

', '
', '""\'\'\'"""\'""<<<>/' ]; foreach ($invalid as $input) { $value->setContent($input); $this->assertEquals( 'test-link', $value->getElementsByTagName('a')->item(0)->getAttribute('href'), 'Link data can be extracted from malformed HTML' ); } } public function testMixedNewlines() { $value = new HTML4Value(); $value->setContent("

paragraph

\n
  • 1
  • \r\n
"); $this->assertEquals( "

paragraph

\n
  • 1
  • \n
", $value->getContent(), 'Newlines get converted' ); } public function testAttributeEscaping() { $value = new HTML4Value(); $value->setContent('
'); $this->assertEquals('', $value->getContent(), "'[' character isn't escaped"); $value->setContent(''); $this->assertEquals('', $value->getContent(), "'\"' character is escaped"); } public function testGetContent() { $value = new HTML4Value(); $value->setContent('

This is valid

'); $this->assertEquals('

This is valid

', $value->getContent(), "Valid content is returned"); $value->setContent('valid is false // for instance if a content editor saves something really weird in a LiteralField // we can manually get to this state via ->setInvalid() $value->setInvalid(); $this->assertEquals('', $value->getContent(), "Blank string is returned when invalid"); } }