1<?php
2
3class TestPagebreakTable extends GenericTest {
4  function testPagebreakTable1() {
5    $media = new Media(array('width' => 100, 'height' => 200/mm2pt(1)),
6                       array('top'=>0, 'bottom'=>0, 'left'=>0, 'right'=>0));
7    $tree = $this->runPipeline('
8<html>
9<head>
10body   { font-size: 10pt; line-height: 1; padding: 0; margin: 0; }
11</style>
12</head>
13<body>
14<table cellpadding="0" cellspacing="0">
15<tr><td>TEXT1</td><td>TEXT2</td></tr>
16<tr><td>TEXT3</td><td>TEXT4</td></tr>
17<tr><td>TEXT5</td><td>TEXT6</td></tr>
18</table>
19</body>
20</html>
21', $media);
22
23    $locations = PageBreakLocator::_getBreakLocations($tree);
24    $this->assertEqual(count($locations),
25                       4);
26  }
27
28  function testPagebreakTable2() {
29    $media = new Media(array('width' => 100, 'height' => 200/mm2pt(1)),
30                       array('top'=>0, 'bottom'=>0, 'left'=>0, 'right'=>0));
31    $tree = $this->runPipeline('
32<html>
33<head>
34body   { font-size: 10pt; line-height: 1; padding: 0; margin: 0; }
35table  { line-height: 1; }
36</style>
37</head>
38<body>
39<table cellpadding="0" cellspacing="0" id="table">
40<tr><td id="cell">TEXT1_1<br/>TEXT1_2</td></tr>
41</table>
42</body>
43</html>
44', $media);
45
46    $locations = PageBreakLocator::_getBreakLocations($tree);
47
48    $table = $tree->get_element_by_id('table');
49    $cell  = $tree->get_element_by_id('cell');
50    $line1 = $cell->content[0]->getLineBox(0);
51
52    $this->assertEqual(count($locations),
53                       3,
54                       "Testing number of page breaks inside a table with one cell & several text lines inside [%s]");
55    $this->assertEqual($locations[0]->location,
56                       $table->get_top_margin(),
57                       "First page break should be at the table top [%s]");
58    $this->assertEqual($locations[1]->location,
59                       $line1->bottom,
60                       "Second page break should be at the bottom of the first line box in the table cell [%s]");
61    $this->assertEqual($locations[2]->location,
62                       $table->get_bottom_margin(),
63                       "Last page break should be at the table bottom [%s]");
64  }
65}
66
67?>