Prepended constants with C_ to avoid reserved words as per https://www.php.net/manual...
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / ElementDefTest.php
blob31ef8cf68de905ab572e4f122d4663fe2a415290
1 <?php
3 class HTMLPurifier_ElementDefTest extends HTMLPurifier_Harness
6 public function test_mergeIn()
8 $def1 = new HTMLPurifier_ElementDef();
9 $def2 = new HTMLPurifier_ElementDef();
10 $def3 = new HTMLPurifier_ElementDef();
12 $old = 1;
13 $new = 2;
14 $overloaded_old = 3;
15 $overloaded_new = 4;
16 $removed = 5;
18 $def1->standalone = true;
19 $def1->attr = array(
20 0 => array('old-include'),
21 'old-attr' => $old,
22 'overloaded-attr' => $overloaded_old,
23 'removed-attr' => $removed,
26 $def1->attr_transform_pre =
27 $def1->attr_transform_post = array(
28 'old-transform' => $old,
29 'overloaded-transform' => $overloaded_old,
30 'removed-transform' => $removed,
33 $def1->attr_transform_pre[] = $old;
34 $def1->attr_transform_post[] = $old;
35 $def1->child = $overloaded_old;
36 $def1->content_model = 'old';
37 $def1->content_model_type = $overloaded_old;
38 $def1->descendants_are_inline = false;
39 $def1->excludes = array(
40 'old' => true,
41 'removed-old' => true
44 $def2->standalone = false;
45 $def2->attr = array(
46 0 => array('new-include'),
47 'new-attr' => $new,
48 'overloaded-attr' => $overloaded_new,
49 'removed-attr' => false,
52 $def2->attr_transform_pre =
53 $def2->attr_transform_post = array(
54 'new-transform' => $new,
55 'overloaded-transform' => $overloaded_new,
56 'removed-transform' => false,
59 $def2->attr_transform_pre[] = $new;
60 $def2->attr_transform_post[] = $new;
61 $def2->child = $new;
62 $def2->content_model = '#SUPER | new';
63 $def2->content_model_type = $overloaded_new;
64 $def2->descendants_are_inline = true;
65 $def2->excludes = array(
66 'new' => true,
67 'removed-old' => false
70 $def1->mergeIn($def2);
71 $def1->mergeIn($def3); // empty, has no effect
73 $this->assertIdentical($def1->standalone, true);
74 $this->assertIdentical($def1->attr, array(
75 0 => array('old-include', 'new-include'),
76 'old-attr' => $old,
77 'overloaded-attr' => $overloaded_new,
78 'new-attr' => $new,
79 ));
80 $this->assertIdentical($def1->attr_transform_pre, $def1->attr_transform_post);
81 $this->assertIdentical($def1->attr_transform_pre, array($old, $new));
83 $this->assertIdentical($def1->attr_transform_pre, array(
84 'old-transform' => $old,
85 'overloaded-transform' => $overloaded_new,
86 'new-transform' => $new,
87 ));
89 $this->assertIdentical($def1->child, $new);
90 $this->assertIdentical($def1->content_model, 'old | new');
91 $this->assertIdentical($def1->content_model_type, $overloaded_new);
92 $this->assertIdentical($def1->descendants_are_inline, true);
93 $this->assertIdentical($def1->excludes, array(
94 'old' => true,
95 'new' => true
96 ));
102 // vim: et sw=4 sts=4