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\Debug;
|
---|
14 |
|
---|
15 | use Spipu\Html2Pdf\Debug\Debug;
|
---|
16 | use Spipu\Html2Pdf\Tests\AbstractTest;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Class DebugTest
|
---|
20 | */
|
---|
21 | class DebugTest extends AbstractTest
|
---|
22 | {
|
---|
23 | /**
|
---|
24 | * test Debug Mode, Automatic
|
---|
25 | *
|
---|
26 | * @return void
|
---|
27 | */
|
---|
28 | public function testAutomatic()
|
---|
29 | {
|
---|
30 | $html = '<p>First Tag</p>';
|
---|
31 | $html.= '<div>Second Tag</div>';
|
---|
32 | $html.= '<b>Third Tag</b>';
|
---|
33 |
|
---|
34 | ob_start();
|
---|
35 | $object = $this->getObject();
|
---|
36 | $object->setModeDebug();
|
---|
37 | $object->writeHTML($html);
|
---|
38 | $pdfResult = $object->output('test.pdf', 'S');
|
---|
39 | $debugResult = ob_get_clean();
|
---|
40 |
|
---|
41 | $this->assertSame('', $pdfResult);
|
---|
42 | $this->assertNotEmpty($debugResult);
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * test Debug Mode, manual
|
---|
47 | *
|
---|
48 | * @return void
|
---|
49 | */
|
---|
50 | public function testManual()
|
---|
51 | {
|
---|
52 | $html = '<p>First Tag</p>';
|
---|
53 | $html.= '<div>Second Tag</div>';
|
---|
54 | $html.= '<b>Third Tag</b>';
|
---|
55 |
|
---|
56 | // Prepare debug object, without html output
|
---|
57 | $debug = new Debug(false);
|
---|
58 |
|
---|
59 | ob_start();
|
---|
60 | $object = $this->getObject();
|
---|
61 | $object->setModeDebug($debug);
|
---|
62 | $object->writeHTML($html);
|
---|
63 | $pdfResult = $object->output('test.pdf', 'S');
|
---|
64 | $debugResult = ob_get_clean();
|
---|
65 |
|
---|
66 | $this->assertSame('', $pdfResult);
|
---|
67 | $this->assertNotEmpty($debugResult);
|
---|
68 | }
|
---|
69 |
|
---|
70 | }
|
---|