|
@@ -30,6 +30,9 @@ class ObjectDecoratorTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$array = self::$escaped->getTitles();
|
|
|
$this->assertEquals('<strong>escaped!</strong>', $array[2], 'The escaped object behaves like the real object');
|
|
|
+
|
|
|
+ $this->assertEquals('Hello <strong>Fabien</strong>', self::$escaped->sayHello('Fabien'), 'The escaped object behaves like the real object');
|
|
|
+ $this->assertEquals('Hello <strong>Fabien</strong>', self::$escaped->sayHello('Fabien', 'esc_raw'), 'The escaped object behaves like the real object');
|
|
|
}
|
|
|
|
|
|
public function testMagicToString()
|
|
@@ -47,6 +50,21 @@ class ObjectDecoratorTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertTrue(isset(self::$escaped->someMember), 'The escaped object behaves like the real object');
|
|
|
$this->assertFalse(isset(self::$escaped->invalidMember), 'The escaped object behaves like the real object');
|
|
|
}
|
|
|
+
|
|
|
+ public function testGetRaw()
|
|
|
+ {
|
|
|
+ $this->assertEquals('<em>escape me</em>', self::$escaped->getRaw('someMember'), '->getRaw() returns result with any escaping');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @expectedException LogicException
|
|
|
+ */
|
|
|
+ public function testGetRawException()
|
|
|
+ {
|
|
|
+ $object = new \stdClass();
|
|
|
+ $escaped = Escaper::escape('entities', $object);
|
|
|
+ $escaped->getRaw('something');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class OutputEscaperTest
|
|
@@ -63,8 +81,18 @@ class OutputEscaperTest
|
|
|
return '<strong>escaped!</strong>';
|
|
|
}
|
|
|
|
|
|
+ public function sayHello($name)
|
|
|
+ {
|
|
|
+ return sprintf('Hello <strong>%s</strong>', $name);
|
|
|
+ }
|
|
|
+
|
|
|
public function getTitles()
|
|
|
{
|
|
|
return array(1, 2, '<strong>escaped!</strong>');
|
|
|
}
|
|
|
+
|
|
|
+ public function get($key)
|
|
|
+ {
|
|
|
+ return isset($this->{$key}) ? $this->{$key} : null;
|
|
|
+ }
|
|
|
}
|