From cebb0b494f666f3929aee32699ac2ae155600965 Mon Sep 17 00:00:00 2001 From: Krystian Duma Date: Sun, 8 Nov 2026 21:25:44 +0000 Subject: [PATCH 1/2] fix(cups): preserve explicit false PPD options --- app/Printers/Protocols/CupsProtocol.php | 3 +- tests/Unit/Printers/CupsProtocolTest.php | 51 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/Printers/CupsProtocolTest.php diff --git a/app/Printers/Protocols/CupsProtocol.php b/app/Printers/Protocols/CupsProtocol.php index 8d85c0b..f232598 100644 --- a/app/Printers/Protocols/CupsProtocol.php +++ b/app/Printers/Protocols/CupsProtocol.php @@ -32,8 +32,7 @@ public function printJob(JobModel $job, array $protocol_options): void case 'ppd': $options = collect($job->options) - ->filter(fn ($value) => ! is_bool($value) || $value === true) - ->map(fn ($value) => is_bool($value) ? null : $value); + ->map(fn ($value) => is_bool($value) ? ($value ? 'True' : 'False') : $value); break; default: diff --git a/tests/Unit/Printers/CupsProtocolTest.php b/tests/Unit/Printers/CupsProtocolTest.php new file mode 100644 index 0000000..69722bf --- /dev/null +++ b/tests/Unit/Printers/CupsProtocolTest.php @@ -0,0 +1,51 @@ +commands[] = $cmd; + preg_match("/'([^']+)'$/", $cmd, $match); + $this->content = file_get_contents($match[1]); + + return 'request id is fixture-1'; + } + }; +} + +test('PPD preserves explicit false and true options alongside choice values', function () { + $protocol = recordingCupsProtocol(); + $protocol->printJob(new JobModel('job', 'Test', 'cups://fixture', [ + 'PageSize' => 'A4', + 'Duplex' => 'None', + 'MirrorPrint' => false, + 'fit-to-page' => true, + ], 'ppd', 'label.pdf', 'prepared PDF bytes'), ['host' => 'fixture']); + + expect($protocol->commands)->toHaveCount(1) + ->and($protocol->commands[0])->toContain("-o 'PageSize=A4'", "-o 'Duplex=None'", "-o 'MirrorPrint=False'", "-o 'fit-to-page=True'") + ->and($protocol->content)->toBe('prepared PDF bytes'); +}); + +test('RAW keeps the raw flag and does not apply PPD options', function () { + $protocol = recordingCupsProtocol(); + $protocol->printJob(new JobModel('job', 'Test', 'cups://fixture', [ + 'MirrorPrint' => false, + ], 'raw', 'label.zpl', '^XA^XZ'), ['host' => 'fixture']); + + expect($protocol->commands)->toHaveCount(1) + ->and($protocol->commands[0])->toContain("-o 'raw'")->not->toContain('MirrorPrint') + ->and($protocol->content)->toBe('^XA^XZ'); +}); From 2b8440d21de24b19b6ecf080655595d2fa86533c Mon Sep 17 00:00:00 2001 From: Krystian Duma Date: Sun, 8 Nov 2026 21:31:47 +0000 Subject: [PATCH 2/2] ci: use supported PHAR artifact upload action --- .github/workflows/phar.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phar.yml b/.github/workflows/phar.yml index fb33dc7..ff88ae6 100644 --- a/.github/workflows/phar.yml +++ b/.github/workflows/phar.yml @@ -54,7 +54,7 @@ jobs: run: mv builds/webprint-service builds/webprint-service.phar - name: Upload a Build Artifact - uses: actions/upload-artifact@v2.2.4 + uses: actions/upload-artifact@v4 with: name: binary path: builds/*