diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index 1e236b7a2fda..24c3a2cc2228 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -156,10 +156,12 @@ trait PdfMakerUtilities public function processOptions() { - if (isset($this->options['repeat_header_and_footer']) && $this->options['repeat_header_and_footer']) { - $this->insertPrintCSS(); - $this->wrapIntoTable(); + if (!isset($this->options['all_page_header']) && !isset($this->options['all_page_footer'])) { + return; } + + $this->insertPrintCSS(); + $this->wrapIntoTable(); } public function insertPrintCSS() @@ -256,7 +258,12 @@ trait PdfMakerUtilities $this->document->getElementById('repeat-content')->appendChild($clone); } - if ($header = $this->document->getElementById('header')) { + if ( + $header = $this->document->getElementById('header') && + isset($this->data['options']['all_page_header']) && + $this->data['options']['all_page_header'] + ) { + $header = $this->document->getElementById('header'); $clone = $header->cloneNode(true); @@ -264,7 +271,11 @@ trait PdfMakerUtilities $this->document->getElementById('repeat-header')->appendChild($clone); } - if ($footer = $this->document->getElementById('footer')) { + if ( + $footer = $this->document->getElementById('footer') && + isset($this->data['options']['all_page_footer']) && + $this->data['options']['all_page_footer'] + ) { $footer = $this->document->getElementById('footer'); $clone = $footer->cloneNode(true); diff --git a/tests/Feature/PdfMaker/PdfMakerDesignsTest.php b/tests/Feature/PdfMaker/PdfMakerDesignsTest.php index 831beea78d44..712b8036398a 100644 --- a/tests/Feature/PdfMaker/PdfMakerDesignsTest.php +++ b/tests/Feature/PdfMaker/PdfMakerDesignsTest.php @@ -50,6 +50,8 @@ class PdfMakerDesignsTest extends TestCase ], ], ]; + + exec('echo "" > storage/logs/laravel.log'); } public function testBusiness() @@ -137,16 +139,13 @@ class PdfMakerDesignsTest extends TestCase ], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); - - $maker = new PdfMaker($state); $maker ->design(Business::class) ->build(); - //exec('echo "" > storage/logs/laravel.log'); + exec('echo "" > storage/logs/laravel.log'); info($maker->getCompiledHTML()); @@ -250,7 +249,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -258,8 +256,6 @@ class PdfMakerDesignsTest extends TestCase ->design(Clean::class) ->build(); - //exec('echo "" > storage/logs/laravel.log'); - info($maker->getCompiledHTML(true)); $this->assertTrue(true); @@ -366,7 +362,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -374,6 +369,8 @@ class PdfMakerDesignsTest extends TestCase ->design(Modern::class) ->build(); + info($maker->getCompiledHTML()); + //exec('echo "" > storage/logs/laravel.log'); //info($maker->getCompiledHTML(true)); @@ -381,7 +378,6 @@ class PdfMakerDesignsTest extends TestCase $this->assertTrue(true); } - public function testBold() { $state = [ @@ -483,7 +479,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -491,11 +486,7 @@ class PdfMakerDesignsTest extends TestCase ->design(Bold::class) ->build(); - //exec('echo "" > storage/logs/laravel.log'); - - //info($maker->getCompiledHTML(true)); - - + info($maker->getCompiledHTML()); $this->assertTrue(true); } @@ -593,7 +584,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -601,11 +591,9 @@ class PdfMakerDesignsTest extends TestCase ->design(Plain::class) ->build(); - // exec('echo "" > storage/logs/laravel.log'); - - // info($maker->getCompiledHTML(true)); - + exec('echo "" > storage/logs/laravel.log'); + info($maker->getCompiledHTML(true)); $this->assertTrue(true); } @@ -707,7 +695,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -715,10 +702,7 @@ class PdfMakerDesignsTest extends TestCase ->design(Hipster::class) ->build(); - // exec('echo "" > storage/logs/laravel.log'); - - // info($maker->getCompiledHTML(true)); - + info($maker->getCompiledHTML(true)); $this->assertTrue(true); } @@ -824,7 +808,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -832,10 +815,7 @@ class PdfMakerDesignsTest extends TestCase ->design(Elegant::class) ->build(); - // exec('echo "" > storage/logs/laravel.log'); - - // info($maker->getCompiledHTML(true)); - + info($maker->getCompiledHTML(true)); $this->assertTrue(true); } @@ -941,7 +921,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -949,11 +928,8 @@ class PdfMakerDesignsTest extends TestCase ->design(Creative::class) ->build(); - // exec('echo "" > storage/logs/laravel.log'); - - // info($maker->getCompiledHTML(true)); - + info($maker->getCompiledHTML(true)); $this->assertTrue(true); } @@ -1052,7 +1028,6 @@ class PdfMakerDesignsTest extends TestCase ], 'variables' => array_merge([], $this->state['variables']), ]; - $this->markTestSkipped('STUB broken tests'); $maker = new PdfMaker($state); @@ -1060,11 +1035,7 @@ class PdfMakerDesignsTest extends TestCase ->design(Playful::class) ->build(); - // exec('echo "" > storage/logs/laravel.log'); - - // info($maker->getCompiledHTML(true)); - - + info($maker->getCompiledHTML(true)); $this->assertTrue(true); } diff --git a/tests/Feature/PdfMaker/PdfMakerTest.php b/tests/Feature/PdfMaker/PdfMakerTest.php index a0bff13208dc..49f5d2410031 100644 --- a/tests/Feature/PdfMaker/PdfMakerTest.php +++ b/tests/Feature/PdfMaker/PdfMakerTest.php @@ -18,8 +18,6 @@ class PdfMakerTest extends TestCase public function testDesignLoadsCorrectly() { - $this->markTestSkipped('STUB broken tests'); - $maker = new PdfMaker($this->state); $maker->design(ExampleDesign::class); @@ -29,8 +27,6 @@ class PdfMakerTest extends TestCase public function testHtmlDesignLoadsCorrectly() { - $this->markTestSkipped('STUB broken tests'); - $maker = new PdfMaker($this->state); $maker @@ -42,8 +38,6 @@ class PdfMakerTest extends TestCase public function testGetSectionUtility() { - $this->markTestSkipped('STUB broken tests'); - $maker = new PdfMaker($this->state); $maker @@ -55,8 +49,6 @@ class PdfMakerTest extends TestCase public function testTableAttributesAreInjected() { - $this->markTestSkipped('STUB broken tests'); - $state = [ 'template' => [ 'product-table' => [ @@ -93,8 +85,6 @@ class PdfMakerTest extends TestCase public function testVariablesAreReplaced() { - $this->markTestSkipped('STUB broken tests'); - $state = [ 'template' => [ @@ -133,8 +123,6 @@ class PdfMakerTest extends TestCase public function testElementContentIsGenerated() { - $this->markTestSkipped('STUB broken tests'); - $state = [ 'template' => [ @@ -184,8 +172,6 @@ class PdfMakerTest extends TestCase public function testConditionalRenderingOfElements() { - $this->markTestSkipped('STUB broken tests'); - $maker1 = new PdfMaker([ 'template' => [ @@ -226,8 +212,6 @@ class PdfMakerTest extends TestCase public function testOrderingElements() { - $this->markTestSkipped('STUB broken tests'); - $maker = new PdfMaker([ 'template' => [ @@ -286,8 +270,6 @@ class PdfMakerTest extends TestCase public function testGeneratingPdf() { - $this->markTestSkipped('STUB broken tests'); - $state = [ 'template' => [ @@ -375,7 +357,7 @@ class PdfMakerTest extends TestCase 'values' => [], ], 'options' => [ - 'repeat_header_and_footer' => true, + 'all_page_footer' => true, ], ]; @@ -385,6 +367,10 @@ class PdfMakerTest extends TestCase ->design(ExampleDesign::class) ->build(); + exec('echo "" > storage/logs/laravel.log'); + info($maker->getCompiledHTML(true)); + + $this->assertTrue(true); } } diff --git a/tests/Feature/PdfMaker/example-design.html b/tests/Feature/PdfMaker/example-design.html index 305f12a1762f..2b93c3bd316d 100644 --- a/tests/Feature/PdfMaker/example-design.html +++ b/tests/Feature/PdfMaker/example-design.html @@ -3,6 +3,13 @@ +
1231 +
+ 123123123 +
+
+ /dsadas + Hello world
\ No newline at end of file