[], 'variables' => [ 'labels' => [], 'values' => [], ], ]; public function testDesignLoadsCorrectly() { $design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker = new PdfMaker($this->state); $maker->design($design); $this->assertInstanceOf(Design::class, $maker->design); } public function testHtmlDesignLoadsCorrectly() { $design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker = new PdfMaker($this->state); $maker ->design($design) ->build(); $this->assertStringContainsString('Template: Example', $maker->getCompiledHTML()); } public function testGetSectionUtility() { $design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker = new PdfMaker($this->state); $maker ->design($design) ->build(); $this->assertEquals('table', $maker->getSectionNode('product-table')->nodeName); } public function testTableAttributesAreInjected() { $state = [ 'template' => [ 'product-table' => [ 'id' => 'product-table', 'properties' => [ 'class' => 'my-awesome-class', 'style' => 'margin-top: 10px;', 'script' => 'console.log(1)', ], ], ], 'variables' => [ 'labels' => [], 'values' => [], ], ]; $design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker = new PdfMaker($state); $maker ->design($design) ->build(); $this->assertStringContainsString('my-awesome-class', $maker->getSection('product-table', 'class')); $this->assertStringContainsString('margin-top: 10px;', $maker->getSection('product-table', 'style')); $this->assertStringContainsString('console.log(1)', $maker->getSection('product-table', 'script')); } public function testVariablesAreReplaced() { $state = [ 'template' => [ 'product-table' => [ 'id' => 'product-table', ], ], 'variables' => [ 'labels' => [], 'values' => [ '$company.name' => 'Invoice Ninja', ], ], ]; $design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker = new PdfMaker($state); $maker ->design($design) ->build(); $this->assertStringContainsString('Invoice Ninja', $maker->getCompiledHTML()); $this->assertStringContainsString('Invoice Ninja', $maker->getSection('header')); } public function testElementContentIsGenerated() { $state = [ 'template' => [ 'product-table' => [ 'id' => 'product-table', 'properties' => [], 'elements' => [ ['element' => 'thead', 'content' => '', 'elements' => [ ['element' => 'th', 'content' => 'Company'], ['element' => 'th', 'content' => 'Contact'], ['element' => 'th', 'content' => 'Country', 'properties' => [ 'colspan' => 3, ]], ]], ['element' => 'tr', 'content' => '', 'elements' => [ ['element' => 'td', 'content' => '$company'], ['element' => 'td', 'content' => '$email'], ['element' => 'td', 'content' => '$country', 'elements' => [ ['element' => 'a', 'content' => 'Click here for a link', 'properties' => [ 'href' => 'https://github.com/invoiceninja/invoiceninja', ]], ]], ]], ], ], ], 'variables' => [ 'labels' => [], 'values' => [ '$company' => 'Invoice Ninja', '$email' => 'contact@invoiceninja.com', '$country' => 'UK', ], ], ]; $design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker = new PdfMaker($state); $maker ->design($design) ->build(); $compiled = 'contact@invoiceninja.com'; $this->assertStringContainsString($compiled, $maker->getCompiledHTML()); } public function testConditionalRenderingOfElements() { $design1 = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]); $maker1 = new PdfMaker([ 'template' => [ 'header' => [ 'id' => 'header', 'properties' => [], ], ], ]); $maker1 ->design($design1) ->build(); $output1 = $maker1->getCompiledHTML(); $this->assertStringContainsString('