1 | <?php
|
---|
2 | /**
|
---|
3 | * Html2Pdf Library - Tests
|
---|
4 | *
|
---|
5 | * HTML => PDF converter
|
---|
6 | * distributed under the OSL-3.0 License
|
---|
7 | *
|
---|
8 | * @package Html2pdf
|
---|
9 | * @author Laurent MINGUET <webmaster@html2pdf.fr>
|
---|
10 | * @copyright 2017 Laurent MINGUET
|
---|
11 | */
|
---|
12 |
|
---|
13 | namespace Spipu\Html2Pdf\Tests\Tag;
|
---|
14 |
|
---|
15 | use Spipu\Html2Pdf\Html2Pdf;
|
---|
16 | use Spipu\Html2Pdf\Tests\AbstractTest;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Div Tag test
|
---|
20 | */
|
---|
21 | class DivTest extends AbstractTest
|
---|
22 | {
|
---|
23 | /**
|
---|
24 | * test No Break
|
---|
25 | *
|
---|
26 | * @return void
|
---|
27 | */
|
---|
28 | public function testNoBreak()
|
---|
29 | {
|
---|
30 | $html = '<p>First Tag</p>';
|
---|
31 | $html.= '<div>Second Tag</div>';
|
---|
32 | $html.= '<p>Third Tag</p>';
|
---|
33 |
|
---|
34 | $object = $this->getObject();
|
---|
35 | $object->writeHTML($html);
|
---|
36 | $result = $object->output('test.pdf', 'S');
|
---|
37 |
|
---|
38 | $this->assertNotEmpty($result);
|
---|
39 | $this->assertSame(1, $object->getNbPages());
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * test Break Before
|
---|
44 | *
|
---|
45 | * @return void
|
---|
46 | */
|
---|
47 | public function testBreakBefore()
|
---|
48 | {
|
---|
49 | $html = '<p>First Tag</p>';
|
---|
50 | $html.= '<div style="page-break-before:always">Second Tag</div>';
|
---|
51 | $html.= '<p>Third Tag</p>';
|
---|
52 |
|
---|
53 | $object = $this->getObject();
|
---|
54 | $object->writeHTML($html);
|
---|
55 | $result = $object->output('test.pdf', 'S');
|
---|
56 |
|
---|
57 | $this->assertNotEmpty($result);
|
---|
58 | $this->assertSame(2, $object->getNbPages());
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * test Break After
|
---|
63 | *
|
---|
64 | * @return void
|
---|
65 | */
|
---|
66 | public function testBreakAfter()
|
---|
67 | {
|
---|
68 | $html = '<p>First Tag</p>';
|
---|
69 | $html.= '<div style="page-break-after:always">Second Tag</div>';
|
---|
70 | $html.= '<p>Third Tag</p>';
|
---|
71 |
|
---|
72 | $object = $this->getObject();
|
---|
73 | $object->writeHTML($html);
|
---|
74 | $result = $object->output('test.pdf', 'S');
|
---|
75 |
|
---|
76 | $this->assertNotEmpty($result);
|
---|
77 | $this->assertSame(2, $object->getNbPages());
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * test Break before and After
|
---|
83 | *
|
---|
84 | * @return void
|
---|
85 | */
|
---|
86 | public function testBreakBeforeAndAfter()
|
---|
87 | {
|
---|
88 | $html = '<p>First Tag</p>';
|
---|
89 | $html.= '<div style="page-break-before:always; page-break-after:always">Second Tag</div>';
|
---|
90 | $html.= '<p>Third Tag</p>';
|
---|
91 |
|
---|
92 | $object = $this->getObject();
|
---|
93 | $object->writeHTML($html);
|
---|
94 | $result = $object->output('test.pdf', 'S');
|
---|
95 |
|
---|
96 | $this->assertNotEmpty($result);
|
---|
97 | $this->assertSame(3, $object->getNbPages());
|
---|
98 | }
|
---|
99 | }
|
---|