Prepended constants with C_ to avoid reserved words as per https://www.php.net/manual...
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / PropertyListTest.php
blobd0961959e39b98597665debb6704b0b0a7c03b69
1 <?php
3 class HTMLPurifier_PropertyListTest extends UnitTestCase
6 public function testBasic()
8 $plist = new HTMLPurifier_PropertyList();
9 $plist->set('key', 'value');
10 $this->assertIdentical($plist->get('key'), 'value');
13 public function testNotFound()
15 $this->expectException(new HTMLPurifier_Exception("Key 'key' not found"));
16 $plist = new HTMLPurifier_PropertyList();
17 $plist->get('key');
20 public function testRecursion()
22 $parent_plist = new HTMLPurifier_PropertyList();
23 $parent_plist->set('key', 'value');
24 $plist = new HTMLPurifier_PropertyList();
25 $plist->setParent($parent_plist);
26 $this->assertIdentical($plist->get('key'), 'value');
29 public function testOverride()
31 $parent_plist = new HTMLPurifier_PropertyList();
32 $parent_plist->set('key', 'value');
33 $plist = new HTMLPurifier_PropertyList();
34 $plist->setParent($parent_plist);
35 $plist->set('key', 'value2');
36 $this->assertIdentical($plist->get('key'), 'value2');
39 public function testRecursionNotFound()
41 $this->expectException(new HTMLPurifier_Exception("Key 'key' not found"));
42 $parent_plist = new HTMLPurifier_PropertyList();
43 $plist = new HTMLPurifier_PropertyList();
44 $plist->setParent($parent_plist);
45 $this->assertIdentical($plist->get('key'), 'value');
48 public function testHas()
50 $plist = new HTMLPurifier_PropertyList();
51 $this->assertIdentical($plist->has('key'), false);
52 $plist->set('key', 'value');
53 $this->assertIdentical($plist->has('key'), true);
56 public function testReset()
58 $plist = new HTMLPurifier_PropertyList();
59 $plist->set('key1', 'value');
60 $plist->set('key2', 'value');
61 $plist->set('key3', 'value');
62 $this->assertIdentical($plist->has('key1'), true);
63 $this->assertIdentical($plist->has('key2'), true);
64 $this->assertIdentical($plist->has('key3'), true);
65 $plist->reset('key2');
66 $this->assertIdentical($plist->has('key1'), true);
67 $this->assertIdentical($plist->has('key2'), false);
68 $this->assertIdentical($plist->has('key3'), true);
69 $plist->reset();
70 $this->assertIdentical($plist->has('key1'), false);
71 $this->assertIdentical($plist->has('key2'), false);
72 $this->assertIdentical($plist->has('key3'), false);
75 public function testSquash()
77 $parent = new HTMLPurifier_PropertyList();
78 $parent->set('key1', 'hidden');
79 $parent->set('key2', 2);
80 $plist = new HTMLPurifier_PropertyList($parent);
81 $plist->set('key1', 1);
82 $plist->set('key3', 3);
83 $this->assertIdentical(
84 $plist->squash(),
85 array('key1' => 1, 'key2' => 2, 'key3' => 3)
87 // updates don't show up...
88 $plist->set('key2', 22);
89 $this->assertIdentical(
90 $plist->squash(),
91 array('key1' => 1, 'key2' => 2, 'key3' => 3)
93 // until you force
94 $this->assertIdentical(
95 $plist->squash(true),
96 array('key1' => 1, 'key2' => 22, 'key3' => 3)
101 // vim: et sw=4 sts=4