Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class TestNoteCall extends UnitTestCase {
4
  function runPipeline($html) {
5
    $pipeline = PipelineFactory::create_default_pipeline("", "");
6
    $pipeline->configure(array('scalepoints' => false));
7
 
8
    $pipeline->fetchers = array(new MyFetcherMemory($html, ""));
9
    $pipeline->data_filters[] = new DataFilterHTML2XHTML();
10
    $pipeline->destination = new DestinationFile("test.pdf");
11
 
12
    parse_config_file('../html2ps.config');
13
    $media = Media::predefined("A5");
14
    $pipeline->_prepare($media);
15
    return $pipeline->_layout_item("", $media, 0, $context, $positioned_filter);
16
  }
17
 
18
  function testNoteCallWidthClean() {
19
    $tree = $this->runPipeline('
20
<html><head><style>
21
.footnote {
22
	position: footnote;
23
}
24
</style>
25
</head><body>
26
<p id="p" style="text-align: justify;">
27
TEXT
28
TEXT TEXT TEXT TEXT TEXT TEXT
29
TEXT TEXT TEXT TEXT TEXT TEXT
30
TEXT TEXT TEXT TEXT TEXT TEXT
31
TEXT TEXT TEXT TEXT TEXT TEXT
32
</p>
33
</body></html>
34
');
35
 
36
    $p = $tree->get_element_by_id('p');
37
    $content = $p->content[0];
38
 
39
    $max_right = $p->get_left();
40
    foreach ($content->content as $text) {
41
      $max_right = max($max_right, $text->get_right());
42
    };
43
 
44
    $this->assertTrue($max_right < $p->get_right(),
45
                      sprintf('Right edge of paragraph content (%s) is greater than paragraph right edge (%s)',
46
                              $max_right,
47
                              $p->get_right()));
48
  }
49
 
50
 
51
  function testNoteCallWidth() {
52
    $tree = $this->runPipeline('
53
<html><head><style>
54
.footnote {
55
	position: footnote;
56
}
57
</style>
58
</head><body>
59
<p id="p" style="text-align: justify;">
60
TEXT <span class="footnote">FOOTNOTE</span>
61
TEXT TEXT TEXT TEXT TEXT TEXT
62
TEXT TEXT TEXT TEXT TEXT TEXT
63
TEXT TEXT TEXT TEXT TEXT TEXT
64
TEXT TEXT TEXT TEXT TEXT TEXT
65
</p>
66
</body></html>
67
');
68
 
69
    $p = $tree->get_element_by_id('p');
70
    $content = $p->content[2];
71
 
72
    $max_right = $p->get_left();
73
    foreach ($content->content as $text) {
74
      $max_right = max($max_right, $text->get_right());
75
    };
76
 
77
    $this->assertTrue($max_right < $p->get_right(),
78
                      sprintf('Right edge of paragraph content (%s) is greater than paragraph right edge (%s)',
79
                              $max_right,
80
                              $p->get_right()));
81
  }
82
}
83
 
84
?>