aboutsummaryrefslogtreecommitdiffstats
path: root/lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-12 17:57:41 -0700
committerfriendica <info@friendica.com>2012-07-18 20:40:31 +1000
commit7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch)
treea9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php
parentcd727cb26b78a1dade09d510b071446898477356 (diff)
downloadvolse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.gz
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.bz2
volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.zip
some important stuff we'll need
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php')
-rw-r--r--lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php b/lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php
new file mode 100644
index 000000000..a2d4811ef
--- /dev/null
+++ b/lib/htmlpurifier/tests/HTMLPurifier/PropertyListTest.php
@@ -0,0 +1,93 @@
+<?php
+
+class HTMLPurifier_PropertyListTest extends UnitTestCase
+{
+
+ function testBasic() {
+ $plist = new HTMLPurifier_PropertyList();
+ $plist->set('key', 'value');
+ $this->assertIdentical($plist->get('key'), 'value');
+ }
+
+ function testNotFound() {
+ $this->expectException(new HTMLPurifier_Exception("Key 'key' not found"));
+ $plist = new HTMLPurifier_PropertyList();
+ $plist->get('key');
+ }
+
+ function testRecursion() {
+ $parent_plist = new HTMLPurifier_PropertyList();
+ $parent_plist->set('key', 'value');
+ $plist = new HTMLPurifier_PropertyList();
+ $plist->setParent($parent_plist);
+ $this->assertIdentical($plist->get('key'), 'value');
+ }
+
+ function testOverride() {
+ $parent_plist = new HTMLPurifier_PropertyList();
+ $parent_plist->set('key', 'value');
+ $plist = new HTMLPurifier_PropertyList();
+ $plist->setParent($parent_plist);
+ $plist->set('key', 'value2');
+ $this->assertIdentical($plist->get('key'), 'value2');
+ }
+
+ function testRecursionNotFound() {
+ $this->expectException(new HTMLPurifier_Exception("Key 'key' not found"));
+ $parent_plist = new HTMLPurifier_PropertyList();
+ $plist = new HTMLPurifier_PropertyList();
+ $plist->setParent($parent_plist);
+ $this->assertIdentical($plist->get('key'), 'value');
+ }
+
+ function testHas() {
+ $plist = new HTMLPurifier_PropertyList();
+ $this->assertIdentical($plist->has('key'), false);
+ $plist->set('key', 'value');
+ $this->assertIdentical($plist->has('key'), true);
+ }
+
+ function testReset() {
+ $plist = new HTMLPurifier_PropertyList();
+ $plist->set('key1', 'value');
+ $plist->set('key2', 'value');
+ $plist->set('key3', 'value');
+ $this->assertIdentical($plist->has('key1'), true);
+ $this->assertIdentical($plist->has('key2'), true);
+ $this->assertIdentical($plist->has('key3'), true);
+ $plist->reset('key2');
+ $this->assertIdentical($plist->has('key1'), true);
+ $this->assertIdentical($plist->has('key2'), false);
+ $this->assertIdentical($plist->has('key3'), true);
+ $plist->reset();
+ $this->assertIdentical($plist->has('key1'), false);
+ $this->assertIdentical($plist->has('key2'), false);
+ $this->assertIdentical($plist->has('key3'), false);
+ }
+
+ function testSquash() {
+ $parent = new HTMLPurifier_PropertyList();
+ $parent->set('key1', 'hidden');
+ $parent->set('key2', 2);
+ $plist = new HTMLPurifier_PropertyList($parent);
+ $plist->set('key1', 1);
+ $plist->set('key3', 3);
+ $this->assertIdentical(
+ $plist->squash(),
+ array('key1' => 1, 'key2' => 2, 'key3' => 3)
+ );
+ // updates don't show up...
+ $plist->set('key2', 22);
+ $this->assertIdentical(
+ $plist->squash(),
+ array('key1' => 1, 'key2' => 2, 'key3' => 3)
+ );
+ // until you force
+ $this->assertIdentical(
+ $plist->squash(true),
+ array('key1' => 1, 'key2' => 22, 'key3' => 3)
+ );
+ }
+}
+
+// vim: et sw=4 sts=4