0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-19 18:55:19 +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:
Edward Z. Yang 2006-10-01 18:39:48 +00:00
parent f432a40f50
commit 58be73fcf7
2 changed files with 13 additions and 1 deletions

View File

@ -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]);
}
}
?>

View File

@ -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);