Skip to content

Commit

Permalink
Add unit test for an invalid HTMLValue
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 25, 2019
1 parent 7ea218a commit d285529
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/php/View/Parsers/HTML4ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,19 @@ public function testAttributeEscaping()
$value->setContent('<a href="&quot;"></a>');
$this->assertEquals('<a href="&quot;"></a>', $value->getContent(), "'\"' character is escaped");
}

public function testGetContent()
{
$value = new HTML4Value();

$value->setContent('<p>This is valid</p>');
$this->assertEquals('<p>This is valid</p>', $value->getContent(), "Valid content is returned");

$value->setContent('<p?< This is not really valid but it will get parsed into something valid');
// can sometimes get a this state where HTMLValue->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");
}
}

0 comments on commit d285529

Please sign in to comment.