$this->assertEquals('<strong>escaped!</strong>',Escaper::escape('raw','<strong>escaped!</strong>'),'::escape() takes an escaping strategy function name as its first argument');
$this->assertEquals('<strong>escaped!</strong>',Escaper::escape('entities','<strong>escaped!</strong>'),'::escape() returns an escaped string if the value to escape is a string');
$this->assertEquals('<strong>échappé</strong>',Escaper::escape('entities','<strong>échappé</strong>'),'::escape() returns an escaped string if the value to escape is a string');
$this->assertEquals('<strong>escaped!</strong>',Escaper::escape('entities',$output)->getTitle(),'::escape() does not double escape an object');
$this->assertTrue(Escaper::escape('entities',new\DirectoryIterator('.'))instanceofIteratorDecorator,'::escape() returns a IteratorDecorator object if the value to escape is an object that implements the ArrayAccess interface');
$this->assertTrue(Escaper::escape('entities',newSafeDecorator(newOutputEscaperTestClass()))instanceofOutputEscaperTestClass,'::escape() returns the original value if it is marked as being safe');
$this->assertTrue(Escaper::escape('entities',newOutputEscaperTestClass())instanceofOutputEscaperTestClass,'::escape() returns the original value if the object class is marked as being safe');
$this->assertTrue(Escaper::escape('entities',newOutputEscaperTestClassChild())instanceofOutputEscaperTestClassChild,'::escape() returns the original value if one of the object parent class is marked as being safe');
}
publicfunctiontestEscapeCannotEscapeResources()
{
$fh=fopen(__FILE__,'r');
try
{
Escaper::escape('entities',$fh);
$this->fail('::escape() throws an InvalidArgumentException if the value cannot be escaped');
$this->assertEquals('<strong>escaped!</strong>',Escaper::unescape('<strong>escaped!</strong>'),'::unescape() returns an unescaped string if the value to unescape is a string');
$this->assertEquals('<strong>échappé</strong>',Escaper::unescape('<strong>échappé</strong>'),'::unescape() returns an unescaped string if the value to unescape is a string');
$this->assertTrue(Escaper::unescape(Escaper::escape('entities',newSafeDecorator(newOutputEscaperTestClass())))instanceofOutputEscaperTestClass,'::unescape() returns the original value if it is marked as being safe');
$this->assertTrue(Escaper::unescape(Escaper::escape('entities',newOutputEscaperTestClass()))instanceofOutputEscaperTestClass,'::unescape() returns the original value if the object class is marked as being safe');
$this->assertTrue(Escaper::unescape(Escaper::escape('entities',newOutputEscaperTestClassChild()))instanceofOutputEscaperTestClassChild,'::unescape() returns the original value if one of the object parent class is marked as being safe');