3
0
mirror of https://github.com/snipe/snipe-it.git synced 2025-10-29 11:21:21 +00:00

Avoid dumping pdf contents to test results

This commit is contained in:
Marcus Moore 2025-05-29 15:05:08 -07:00
parent bb68ed3ad9
commit 18d0a04efc
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View File

@ -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);
}
/**

View File

@ -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.');