mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
[1.2.0] Added exists() method to HTMLPurifier_Context.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@483 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
f432a40f50
commit
58be73fcf7
@ -52,6 +52,14 @@ class HTMLPurifier_Context
|
||||
unset($this->_storage[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not the variable exists.
|
||||
* @param $name String name
|
||||
*/
|
||||
function exists($name) {
|
||||
return isset($this->_storage[$name]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -18,13 +18,17 @@ class HTMLPurifier_ContextTest extends UnitTestCase
|
||||
|
||||
generate_mock_once('HTMLPurifier_IDAccumulator');
|
||||
|
||||
$this->assertFalse($this->context->exists('IDAccumulator'));
|
||||
|
||||
$accumulator =& new HTMLPurifier_IDAccumulatorMock($this);
|
||||
$this->context->register('IDAccumulator', $accumulator);
|
||||
// ...
|
||||
$this->assertTrue($this->context->exists('IDAccumulator'));
|
||||
|
||||
$accumulator_2 =& $this->context->get('IDAccumulator');
|
||||
$this->assertReference($accumulator, $accumulator_2);
|
||||
|
||||
$this->context->destroy('IDAccumulator');
|
||||
$this->assertFalse($this->context->exists('IDAccumulator'));
|
||||
$accumulator_3 =& $this->context->get('IDAccumulator');
|
||||
$this->assertError('Attempted to retrieve non-existent variable');
|
||||
$this->assertNull($accumulator_3);
|
||||
|
Loading…
Reference in New Issue
Block a user