[OutputEscaper] Added magic __isset() method to object escaper.
This commit is contained in:
parent
ab26f9f3bf
commit
fe7e01c653
@ -106,4 +106,16 @@ class ObjectDecorator extends GetterDecorator
|
||||
{
|
||||
return $this->escape($this->escaper, $this->value->$key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a value is set on the wrapped object.
|
||||
*
|
||||
* @param string $key The name of the value to check
|
||||
*
|
||||
* @return boolean Returns true if the value is set
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return isset($this->value->$key);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,12 @@ class ObjectDecoratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->assertEquals('<em>escape me</em>', self::$escaped->someMember, 'The escaped object behaves like the real object');
|
||||
}
|
||||
|
||||
public function testMagicIsset()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
||||
class OutputEscaperTest
|
||||
|
Reference in New Issue
Block a user