Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
carli2 committed May 24, 2024
1 parent d60c359 commit 90a1383
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Issues/Issue2013Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Issues;

class Issue2013Test extends \Yoast\PHPUnitPolyfills\TestCases\TestCase
{

public function testPdfTableBreakAvoidTooMuch()
{
// test case: spill items that take about a bit more than half a page, no page-break-avoid would fit them on two pages, with page-break it will be three
$mpdf = new \Mpdf\Mpdf();
$html = '';
$itemsPerTwothirdsPage = 28;
for ($i = 0; $i < 5*$itemsPerTwothirdsPage; $i++) {
$html .= '<tr style="page-break-before: avoid; background: lime;"><td>content</td></tr>';
}
$mpdf->WriteHTML('<html><body><h1>Test</h1>
<table>'.$html.'</table>
</html>');

// without the bugfix, it would produce 98 pages, with the bugfix: 7
$this->assertEquals($mpdf->page, 7);
}

}

0 comments on commit 90a1383

Please sign in to comment.