| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class TestCSSContent extends GenericTest {
|
|
|
4 |
function testCSSContentWithEscapesInsideHTML() {
|
|
|
5 |
$tree = $this->runPipeline(file_get_contents('test.css.content.1.html'));
|
|
|
6 |
|
|
|
7 |
$element0 =& $tree->get_element_by_id('div1');
|
|
|
8 |
$element = $element0->content[1];
|
|
|
9 |
|
|
|
10 |
$content =& $element->getCSSProperty(CSS_CONTENT);
|
|
|
11 |
|
|
|
12 |
$counters =& new CSSCounterCollection();
|
|
|
13 |
$this->assertEqual($content->render($counters), "<span style="font-weight: bold;">My</span> Page");
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
function testCSSContentWithEscapes() {
|
|
|
17 |
$null = null;
|
|
|
18 |
$collection =& parse_css_property('content: "<span style="font-weight: bold;">My</span> Page";', $null);
|
|
|
19 |
|
|
|
20 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
21 |
|
|
|
22 |
$counters =& new CSSCounterCollection();
|
|
|
23 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
24 |
$this->assertEqual($content->render($counters), "<span style="font-weight: bold;">My</span> Page");
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
function testCSSHTMLContentWithEscapes() {
|
|
|
28 |
$null = null;
|
|
|
29 |
$collection =& parse_css_property('-html2ps-html-content: "<span style="font-weight: bold;">My</span> Page";', $null);
|
|
|
30 |
|
|
|
31 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
32 |
|
|
|
33 |
$counters =& new CSSCounterCollection();
|
|
|
34 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
35 |
$this->assertEqual($content->render($counters), "<span style="font-weight: bold;">My</span> Page");
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
function testCSSContentWithCounters() {
|
|
|
39 |
$null = null;
|
|
|
40 |
$collection =& parse_css_property('content: "Page " counter(page) " of " counter(pages);', $null);
|
|
|
41 |
|
|
|
42 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
43 |
|
|
|
44 |
$counters =& new CSSCounterCollection();
|
|
|
45 |
|
|
|
46 |
$page_counter =& new CSSCounter('page');
|
|
|
47 |
$page_counter->set(10);
|
|
|
48 |
$counters->add($page_counter);
|
|
|
49 |
|
|
|
50 |
$sample_counter =& new CSSCounter('sample');
|
|
|
51 |
$sample_counter->set(1);
|
|
|
52 |
$counters->add($sample_counter);
|
|
|
53 |
|
|
|
54 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
55 |
$this->assertEqual($content->render($counters), "Page 10 of ");
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
function testCSSContentWithCountersAndSemicolons() {
|
|
|
59 |
$null = null;
|
|
|
60 |
$collection =& parse_css_property('content: "Page; " counter(page) " of; " counter(pages);', $null);
|
|
|
61 |
|
|
|
62 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
63 |
|
|
|
64 |
$counters =& new CSSCounterCollection();
|
|
|
65 |
|
|
|
66 |
$page_counter =& new CSSCounter('page');
|
|
|
67 |
$page_counter->set(1);
|
|
|
68 |
$counters->add($page_counter);
|
|
|
69 |
|
|
|
70 |
$sample_counter =& new CSSCounter('pages');
|
|
|
71 |
$sample_counter->set(10);
|
|
|
72 |
$counters->add($sample_counter);
|
|
|
73 |
|
|
|
74 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
75 |
$this->assertEqual($content->render($counters), "Page; 1 of; 10");
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
function testCSSContentEmptyWithQuotes() {
|
|
|
79 |
$null = null;
|
|
|
80 |
$collection =& parse_css_property('content: "";', $null);
|
|
|
81 |
|
|
|
82 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
83 |
|
|
|
84 |
$counters =& new CSSCounterCollection();
|
|
|
85 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
86 |
$this->assertEqual($content->render($counters), "");
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
function testCSSContentEmptyWithApostrophes() {
|
|
|
90 |
$null = null;
|
|
|
91 |
$collection =& parse_css_property('content: \'\';', $null);
|
|
|
92 |
|
|
|
93 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
94 |
|
|
|
95 |
$counters =& new CSSCounterCollection();
|
|
|
96 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
97 |
$this->assertEqual($content->render($counters), "");
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
function testCSSContentEmptyWithOtherProperties() {
|
|
|
101 |
$null = null;
|
|
|
102 |
$collection =& parse_css_properties("-html2ps-html-content: ''; content: ''; width: auto; height: auto; margin: 0; border: none; padding: 0; font: auto;", $null);
|
|
|
103 |
|
|
|
104 |
$this->assertTrue($collection->contains(CSS_CONTENT));
|
|
|
105 |
$this->assertTrue($collection->contains(CSS_HTML2PS_HTML_CONTENT));
|
|
|
106 |
|
|
|
107 |
$counters =& new CSSCounterCollection();
|
|
|
108 |
|
|
|
109 |
$content =& $collection->getPropertyValue(CSS_CONTENT);
|
|
|
110 |
$this->assertEqual($content->render($counters), "");
|
|
|
111 |
|
|
|
112 |
$content =& $collection->getPropertyValue(CSS_HTML2PS_HTML_CONTENT);
|
|
|
113 |
$this->assertEqual($content->render($counters), "");
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
?>
|