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*#'); })->with(['invoice', 'delivery', 'credit', 'cancellation', 'credit_details', 'credit_details_long']); test('every pdf translation key used in the templates exists', function (string $locale) { $keys = collect(File::files(resource_path('views/pdf'))) ->flatMap(fn ($file) => preg_match_all("/__\\('(pdf\\.[^']+)'/", $file->getContents(), $matches) ? $matches[1] : []) ->unique(); expect($keys)->not->toBeEmpty() ->and($keys->reject(fn ($key) => trans()->hasForLocale($key, $locale))->values()->all())->toBe([]); })->with(['de', 'en', 'es', 'fr']); test('the rendered pdf can be laid onto the letterhead template', function () { $file = (new InvoicePDF('pdf-probe'))->create([], 'probe.pdf', 'save', $this->pdfDir); $merged = (new MyPDFMerger)->addPDF($file)->myMerge('string', 'probe.pdf', 'template_invoice_de'); File::put($this->pdfDir.'merged.pdf', $merged); expect($merged)->toStartWith('%PDF') ->and((new Fpdi)->setSourceFile($this->pdfDir.'merged.pdf'))->toBe(2); });