stehen (wie in credit_details).
*/
beforeEach(function () {
$this->pdfDir = storage_path('framework/testing/pdf-pipeline-'.uniqid()).'/';
File::ensureDirectoryExists($this->pdfDir);
View::addLocation($this->pdfDir);
File::put($this->pdfDir.'pdf-probe.blade.php', <<<'BLADE'
Seite eins
Seite zwei
BLADE);
$GLOBALS['pdfProbePages'] = [];
});
afterEach(function () {
File::deleteDirectory($this->pdfDir);
unset($GLOBALS['pdfProbePages']);
});
test('embedded php runs on every page of an invoice pdf', function () {
$file = (new InvoicePDF('pdf-probe'))->create([], 'probe.pdf', 'save', $this->pdfDir);
expect($file)->toBe($this->pdfDir.'probe.pdf')
->and(file_get_contents($file))->toStartWith('%PDF')
->and($GLOBALS['pdfProbePages'])->toBe(['1/2', '2/2']);
});
test('page numbers are added at the end of the template so they reach every page', function (string $template) {
$view = file_get_contents(resource_path("views/pdf/{$template}.blade.php"));
expect(substr_count($view, 'type="text/php"'))->toBe(1)
->and($view)->toMatch('#\s*