Skip to content

A free open source IT asset/license management system

Avoid dumping pdf contents to test results

Marcus Moore18d0a04efc93
diff --git a/app/View/Label.php b/app/View/Label.php
index d168be883b..ee9a1ae2fd 100644
--- a/app/View/Label.php
+++ b/app/View/Label.php
@@ -25,6 +25,16 @@ class Label implements View
*/
protected $data;
+
+ /**
+ * TCPDF output destination.
+ * "I" - inline by default.
+ * See TCPDF's Output method for details.
+ *
+ * @var string
+ */
+ private string $destination = 'I';
+
public function __construct() {
$this->data = new Collection();
}
@@ -222,7 +232,7 @@ class Label implements View
$template->writeAll($pdf, $data);
$filename = $assets->count() > 1 ? 'assets.pdf' : $assets->first()->asset_tag.'.pdf';
- $pdf->Output($filename, 'I');
+ $pdf->Output($filename, $this->destination);
}
/**
diff --git a/tests/Unit/Labels/LabelTest.php b/tests/Unit/Labels/LabelTest.php
index a0e1c05348..29bbecd74d 100644
--- a/tests/Unit/Labels/LabelTest.php
+++ b/tests/Unit/Labels/LabelTest.php
@@ -7,6 +7,7 @@ use App\Models\Location;
use App\Models\Setting;
use App\View\Label;
use Tests\TestCase;
+use function Livewire\invade;
class LabelTest extends TestCase
{
@@ -32,6 +33,9 @@ class LabelTest extends TestCase
->with('bulkedit', true)
->with('count', 0);
+ // a simple way to avoid flooding test output with PDF characters.
+ invade($label)->destination = 'S';
+
$label->render();
$this->assertTrue(true, 'Label rendering should not throw an error when location is not set on an asset.');