Rewrite CSS url() and font-family output logic.
[htmlpurifier.git] / tests / HTMLPurifier / PropertyListTest.php
bloba2d4811ef2fd88da46c2dc93ce647910e61bef7c
1 <?php
3 class HTMLPurifier_PropertyListTest extends UnitTestCase
6 function testBasic() {
7 $plist = new HTMLPurifier_PropertyList();
8 $plist->set('key', 'value');
9 $this->assertIdentical($plist->get('key'), 'value');
12 function testNotFound() {
13 $this->expectException(new HTMLPurifier_Exception("Key 'key' not found"));
14 $plist = new HTMLPurifier_PropertyList();
15 $plist->get('key');
18 function testRecursion() {
19 $parent_plist = new HTMLPurifier_PropertyList();
20 $parent_plist->set('key', 'value');
21 $plist = new HTMLPurifier_PropertyList();
22 $plist->setParent($parent_plist);
23 $this->assertIdentical($plist->get('key'), 'value');
26 function testOverride() {
27 $parent_plist = new HTMLPurifier_PropertyList();
28 $parent_plist->set('key', 'value');
29 $plist = new HTMLPurifier_PropertyList();
30 $plist->setParent($parent_plist);
31 $plist->set('key', 'value2');
32 $this->assertIdentical($plist->get('key'), 'value2');
35 function testRecursionNotFound() {
36 $this->expectException(new HTMLPurifier_Exception("Key 'key' not found"));
37 $parent_plist = new HTMLPurifier_PropertyList();
38 $plist = new HTMLPurifier_PropertyList();
39 $plist->setParent($parent_plist);
40 $this->assertIdentical($plist->get('key'), 'value');
43 function testHas() {
44 $plist = new HTMLPurifier_PropertyList();
45 $this->assertIdentical($plist->has('key'), false);
46 $plist->set('key', 'value');
47 $this->assertIdentical($plist->has('key'), true);
50 function testReset() {
51 $plist = new HTMLPurifier_PropertyList();
52 $plist->set('key1', 'value');
53 $plist->set('key2', 'value');
54 $plist->set('key3', 'value');
55 $this->assertIdentical($plist->has('key1'), true);
56 $this->assertIdentical($plist->has('key2'), true);
57 $this->assertIdentical($plist->has('key3'), true);
58 $plist->reset('key2');
59 $this->assertIdentical($plist->has('key1'), true);
60 $this->assertIdentical($plist->has('key2'), false);
61 $this->assertIdentical($plist->has('key3'), true);
62 $plist->reset();
63 $this->assertIdentical($plist->has('key1'), false);
64 $this->assertIdentical($plist->has('key2'), false);
65 $this->assertIdentical($plist->has('key3'), false);
68 function testSquash() {
69 $parent = new HTMLPurifier_PropertyList();
70 $parent->set('key1', 'hidden');
71 $parent->set('key2', 2);
72 $plist = new HTMLPurifier_PropertyList($parent);
73 $plist->set('key1', 1);
74 $plist->set('key3', 3);
75 $this->assertIdentical(
76 $plist->squash(),
77 array('key1' => 1, 'key2' => 2, 'key3' => 3)
79 // updates don't show up...
80 $plist->set('key2', 22);
81 $this->assertIdentical(
82 $plist->squash(),
83 array('key1' => 1, 'key2' => 2, 'key3' => 3)
85 // until you force
86 $this->assertIdentical(
87 $plist->squash(true),
88 array('key1' => 1, 'key2' => 22, 'key3' => 3)
93 // vim: et sw=4 sts=4