| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class TestCSSParse extends GenericTest {
|
|
|
4 |
function testCSSParsePropertyUpperCase() {
|
|
|
5 |
$null = null;
|
|
|
6 |
$collection =& parse_css_property('VISIBILITY: hidden;', $null);
|
|
|
7 |
$this->assertTrue($collection->contains(CSS_VISIBILITY));
|
|
|
8 |
$this->assertEqual($collection->getPropertyValue(CSS_VISIBILITY), VISIBILITY_HIDDEN);
|
|
|
9 |
}
|
|
|
10 |
|
|
|
11 |
function testCSSParsePropertyMixedCase() {
|
|
|
12 |
$null = null;
|
|
|
13 |
$collection =& parse_css_property('VISibiLitY: hidden;', $null);
|
|
|
14 |
$this->assertTrue($collection->contains(CSS_VISIBILITY));
|
|
|
15 |
$this->assertEqual($collection->getPropertyValue(CSS_VISIBILITY), VISIBILITY_HIDDEN);
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
function testCSSParseProperty() {
|
|
|
19 |
$null = null;
|
|
|
20 |
$collection =& parse_css_property('-html2ps-html-content: "Sample;Text";', $null);
|
|
|
21 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
22 |
|
|
|
23 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
24 |
$counters =& new CSSCounterCollection();
|
|
|
25 |
$this->assertEqual($content->render($counters), "Sample;Text");
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
function testCSSParsePropertyWithoutTrailingSemicolon() {
|
|
|
29 |
$null = null;
|
|
|
30 |
$collection =& parse_css_property('content: "TEXT"', $null);
|
|
|
31 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
32 |
|
|
|
33 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
34 |
$counters =& new CSSCounterCollection();
|
|
|
35 |
$this->assertEqual($content->render($counters), "TEXT");
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
function testCSSParsePropertyMultipart() {
|
|
|
39 |
$null = null;
|
|
|
40 |
$collection =& parse_css_property('-html2ps-html-content: "Double Quoted String" \'Single Quoted String\';', $null);
|
|
|
41 |
|
|
|
42 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
43 |
|
|
|
44 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
45 |
$counters =& new CSSCounterCollection();
|
|
|
46 |
$this->assertEqual($content->render($counters), "Double Quoted StringSingle Quoted String");
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
function testCSSParseProperties() {
|
|
|
50 |
$null = null;
|
|
|
51 |
$collection =& parse_css_properties('font-weight: bold; -html2ps-html-content: "Sample;Text"; color: red;', $null);
|
|
|
52 |
|
|
|
53 |
$properties = $collection->getPropertiesRaw();
|
|
|
54 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
55 |
$this->assertTrue($collection->contains(CSS_COLOR));
|
|
|
56 |
$this->assertTrue($collection->contains(CSS_FONT_WEIGHT));
|
|
|
57 |
|
|
|
58 |
$this->assertEqual($collection->getPropertyValue(CSS_FONT_WEIGHT), WEIGHT_BOLD);
|
|
|
59 |
|
|
|
60 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
61 |
$counters =& new CSSCounterCollection();
|
|
|
62 |
$this->assertEqual($content->render($counters), "Sample;Text");
|
|
|
63 |
|
|
|
64 |
$color = $collection->getPropertyValue(CSS_COLOR);
|
|
|
65 |
$this->assertEqual($color->r, 1);
|
|
|
66 |
$this->assertEqual($color->g, 0);
|
|
|
67 |
$this->assertEqual($color->b, 0);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
function testCSSParsePropertiesMultiline() {
|
|
|
71 |
$null = null;
|
|
|
72 |
$collection =& parse_css_properties('font-weight: bold;
|
|
|
73 |
-html2ps-html-content: "Sample;Text";
|
|
|
74 |
color: red;', $null);
|
|
|
75 |
|
|
|
76 |
$properties = $collection->getPropertiesRaw();
|
|
|
77 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
78 |
$this->assertTrue($collection->contains(CSS_COLOR));
|
|
|
79 |
$this->assertTrue($collection->contains(CSS_FONT_WEIGHT));
|
|
|
80 |
|
|
|
81 |
$this->assertEqual($collection->getPropertyValue(CSS_FONT_WEIGHT), WEIGHT_BOLD);
|
|
|
82 |
|
|
|
83 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
84 |
$counters =& new CSSCounterCollection();
|
|
|
85 |
$this->assertEqual($content->render($counters), "Sample;Text");
|
|
|
86 |
|
|
|
87 |
$color = $collection->getPropertyValue(CSS_COLOR);
|
|
|
88 |
$this->assertEqual($color->r, 1);
|
|
|
89 |
$this->assertEqual($color->g, 0);
|
|
|
90 |
$this->assertEqual($color->b, 0);
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
function testCSSParsePropertiesMultilineWithoutTrailingSemicolon() {
|
|
|
94 |
$null = null;
|
|
|
95 |
$collection =& parse_css_properties('font-weight: bold;
|
|
|
96 |
-html2ps-html-content: "Sample;Text";
|
|
|
97 |
color: red', $null);
|
|
|
98 |
|
|
|
99 |
$properties = $collection->getPropertiesRaw();
|
|
|
100 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
101 |
$this->assertTrue($collection->contains(CSS_COLOR));
|
|
|
102 |
$this->assertTrue($collection->contains(CSS_FONT_WEIGHT));
|
|
|
103 |
|
|
|
104 |
$this->assertEqual($collection->getPropertyValue(CSS_FONT_WEIGHT), WEIGHT_BOLD);
|
|
|
105 |
|
|
|
106 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
107 |
$counters =& new CSSCounterCollection();
|
|
|
108 |
$this->assertEqual($content->render($counters), "Sample;Text");
|
|
|
109 |
|
|
|
110 |
$color = $collection->getPropertyValue(CSS_COLOR);
|
|
|
111 |
$this->assertEqual($color->r, 1);
|
|
|
112 |
$this->assertEqual($color->g, 0);
|
|
|
113 |
$this->assertEqual($color->b, 0);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
function testCSSParsePropertiesMultilineWithoutTrailingSemicolon2() {
|
|
|
117 |
$null = null;
|
|
|
118 |
$collection =& parse_css_properties('font-weight: bold;
|
|
|
119 |
-html2ps-html-content: "Sample;Text";
|
|
|
120 |
color: red
|
|
|
121 |
|
|
|
122 |
', $null);
|
|
|
123 |
|
|
|
124 |
$properties = $collection->getPropertiesRaw();
|
|
|
125 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
126 |
$this->assertTrue($collection->contains(CSS_COLOR));
|
|
|
127 |
$this->assertTrue($collection->contains(CSS_FONT_WEIGHT));
|
|
|
128 |
|
|
|
129 |
$this->assertEqual($collection->getPropertyValue(CSS_FONT_WEIGHT), WEIGHT_BOLD);
|
|
|
130 |
|
|
|
131 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
132 |
$counters =& new CSSCounterCollection();
|
|
|
133 |
$this->assertEqual($content->render($counters), "Sample;Text");
|
|
|
134 |
|
|
|
135 |
$color = $collection->getPropertyValue(CSS_COLOR);
|
|
|
136 |
$this->assertEqual($color->r, 1);
|
|
|
137 |
$this->assertEqual($color->g, 0);
|
|
|
138 |
$this->assertEqual($color->b, 0);
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
function testCSSParsePropertiesMultilineWithLinefeedsAround() {
|
|
|
142 |
$null = null;
|
|
|
143 |
$collection =& parse_css_properties('
|
|
|
144 |
font-weight: bold;
|
|
|
145 |
-html2ps-html-content: "Sample;Text";
|
|
|
146 |
color: red;
|
|
|
147 |
', $null);
|
|
|
148 |
|
|
|
149 |
$properties = $collection->getPropertiesRaw();
|
|
|
150 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
151 |
$this->assertTrue($collection->contains(CSS_COLOR));
|
|
|
152 |
$this->assertTrue($collection->contains(CSS_FONT_WEIGHT));
|
|
|
153 |
|
|
|
154 |
$this->assertEqual($collection->getPropertyValue(CSS_FONT_WEIGHT), WEIGHT_BOLD);
|
|
|
155 |
|
|
|
156 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
157 |
$counters =& new CSSCounterCollection();
|
|
|
158 |
$this->assertEqual($content->render($counters), "Sample;Text");
|
|
|
159 |
|
|
|
160 |
$color = $collection->getPropertyValue(CSS_COLOR);
|
|
|
161 |
$this->assertEqual($color->r, 1);
|
|
|
162 |
$this->assertEqual($color->g, 0);
|
|
|
163 |
$this->assertEqual($color->b, 0);
|
|
|
164 |
}
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
?>
|