Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function show(PrintJob $job)
->mapWithKeys(function ($option, $key) use ($options): array {
$value = isset($options[$option['key']]) ? ($options[$option['key']] ?? $option['default']) : $option['default'];

if ($option['type'] ?? 'select' == 'Boolean') {
if (($option['type'] ?? 'select') === 'Boolean') {
return [$option['key'] => $value == 'True'];
}

Expand Down
32 changes: 32 additions & 0 deletions tests/Feature/PrintServiceApi/GetJobDetailsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,38 @@ public function test_long_content_is_served_as_link(): void
);
}

public function test_ppd_choice_values_are_preserved_and_only_booleans_are_converted(): void
{
Sanctum::actingAs(
$server = PrintServer::factory()->create(),
guard: 'print_service_api'
);

$printer = Printer::factory()->for($server, 'Server')->ppd()->create([
'ppd_options' => [
['key' => 'PageSize', 'type' => 'PickOne', 'default' => 'Letter'],
['key' => 'Duplex', 'type' => 'PickOne', 'default' => 'None'],
['key' => 'Resolution', 'default' => '300dpi'],
['key' => 'fit-to-page', 'type' => 'Boolean', 'default' => 'True'],
['key' => 'MirrorPrint', 'type' => 'Boolean', 'default' => 'True'],
],
]);
$job = PrintJob::factory()->for($printer, 'Printer')->create([
'ppd' => true,
'ppd_options' => ['PageSize' => 'A4', 'fit-to-page' => 'False'],
]);

$this->getJson('/api/print-service/jobs/'.$job->ulid)
->assertOk()
->assertJsonPath('options', [
'PageSize' => 'A4',
'Duplex' => 'None',
'Resolution' => '300dpi',
'fit-to-page' => false,
'MirrorPrint' => true,
]);
}

public function test_cannot_access_others_jobs(): void
{
Sanctum::actingAs(
Expand Down
Loading