diff --git a/services/nginx/app/tests/Unit/Invoicing/CollectedInvoiceQueueRouteHardeningTest.php b/services/nginx/app/tests/Unit/Invoicing/CollectedInvoiceQueueRouteHardeningTest.php index 51cb9ab0..fa8e2ddf 100644 --- a/services/nginx/app/tests/Unit/Invoicing/CollectedInvoiceQueueRouteHardeningTest.php +++ b/services/nginx/app/tests/Unit/Invoicing/CollectedInvoiceQueueRouteHardeningTest.php @@ -15,9 +15,9 @@ it('returns pagination metadata and strict status handling for collected-invoice $endpointBlock = substr($content, (int)$start, (int)$end - (int)$start); expect($endpointBlock)->toContain('$statuses = $this->parseCollectedInvoiceQueueStatuses();'); expect($endpointBlock)->toContain("['limit' => \$limit, 'offset' => \$offset] = \$this->parseCollectedInvoiceQueuePagination();"); - expect($endpointBlock)->toContain('$jobs = $queue->listJobs('); + expect($endpointBlock)->toContain('$jobs = $queue->listJobsForCreatedBy('); expect($endpointBlock)->toContain('economic_transfer_queue::TYPE_COLLECTED_INVOICE_EXPORT'); - expect($endpointBlock)->toContain('$total_jobs = $this->countCollectedInvoiceQueueJobs($queue, $statuses);'); + expect($endpointBlock)->toContain('$total_jobs = $this->countCollectedInvoiceQueueJobs($queue, $statuses, (int)$user->id);'); expect($endpointBlock)->toContain("'items' => \$this->withCollectedInvoiceQueueDetailsSummaryList(\$jobs)"); expect($endpointBlock)->toContain("'total' => \$total_jobs"); expect($endpointBlock)->toContain("'limit' => \$limit"); @@ -48,7 +48,7 @@ it('enforces retry constraints for collected-invoice queue jobs before retry exe $endpointBlock = substr($content, (int)$start, (int)$end - (int)$start); expect($endpointBlock)->toContain('$job_id = $this->requireCollectedInvoiceQueueJobId();'); - expect($endpointBlock)->toContain('$job = $this->requireCollectedInvoiceQueueJobById($job_id, true);'); + expect($endpointBlock)->toContain('$job = $this->requireCollectedInvoiceQueueJobById($job_id, (int)$user->id, true);'); expect($endpointBlock)->toContain("Collected invoice queue job reached max retry attempts', 409"); expect($endpointBlock)->toContain('Failed to retry collected invoice queue job: '); expect($endpointBlock)->toContain("'job' => \$this->withCollectedInvoiceQueueDetailsSummary(\$retried)"); @@ -56,7 +56,7 @@ it('enforces retry constraints for collected-invoice queue jobs before retry exe expect($content)->toContain("\$response->success(\$this->withCollectedInvoiceQueueDetailsSummary(\$job));"); expect($content)->toContain('private function requireCollectedInvoiceQueueJobId(): int'); - expect($content)->toContain('private function requireCollectedInvoiceQueueJobById(int $job_id, bool $mustBeFailed = false): array'); + expect($content)->toContain('private function requireCollectedInvoiceQueueJobById(int $job_id, int $created_by, bool $mustBeFailed = false): array'); expect($content)->toContain("Collected invoice queue job can only be retried when status is FAILED', 409"); expect($content)->toContain('private function withCollectedInvoiceQueueDetailsSummary(array $job): array'); expect($content)->toContain('private function withCollectedInvoiceQueueDetailsSummaryList(array $jobs): array'); diff --git a/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php b/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php index 5c4330c9..56c18f8f 100644 --- a/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php +++ b/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php @@ -666,7 +666,7 @@ it('rebuilds automatic invoice period data on cache misses instead of hiding war expect($content)->not->toBeFalse(); $content = (string)$content; - expect($content)->toContain('$flags = $this->buildAutomaticFlagsForPeriod($dateFrom, $dateTo);'); + expect($content)->toContain('$flags = $this->calculateAutomaticFlagsForPeriod($dateFrom, $dateTo);'); expect($content)->toContain('$rows = $this->fetchOrderItemRowsFromDb($dateFrom, $dateTo);'); expect($content)->toContain('cache_invoice_period_order_item_rows($dateFrom, $dateTo, $rows)'); expect($content)->not->toContain('enqueue_invoice_period_warming($dateFrom, $dateTo)'); diff --git a/services/nginx/app/tests/Unit/Invoicing/InvoicingPeriodRouteGuardsTest.php b/services/nginx/app/tests/Unit/Invoicing/InvoicingPeriodRouteGuardsTest.php index 99b856cb..a298db52 100644 --- a/services/nginx/app/tests/Unit/Invoicing/InvoicingPeriodRouteGuardsTest.php +++ b/services/nginx/app/tests/Unit/Invoicing/InvoicingPeriodRouteGuardsTest.php @@ -45,7 +45,7 @@ it('streams the main period response instead of encoding the full payload at onc $content = (string)$content; expect($content)->toContain('private static function streamInvoicingPeriodResponse(array $period): void') - ->and($content)->toContain("$includeInvoicePeriodFlags = $this->hasPermission('list_invoice_period_flags');") + ->and($content)->toContain("\$includeInvoicePeriodFlags = \$this->hasPermission('list_invoice_period_flags');") ->and($content)->toContain('$period = self::getInvoicingPeriod($dateFrom, $dateTo, $customerNumbers, $includeInvoicePeriodFlags);') ->and($content)->toContain('self::streamInvoicingPeriodResponse($period);') ->and($content)->not->toContain('$response->success([' . PHP_EOL . ' ...self::getInvoicingPeriod($dateFrom, $dateTo, $customerNumbers)') @@ -59,7 +59,7 @@ it('only includes invoice period flags when the list permission is granted', fun $content = (string)$content; expect($content) - ->toContain("$includeInvoicePeriodFlags = $this->hasPermission('list_invoice_period_flags');") + ->toContain("\$includeInvoicePeriodFlags = \$this->hasPermission('list_invoice_period_flags');") ->and($content)->toContain('bool $includeInvoicePeriodFlags = false') ->and($content)->toContain('if ($includeInvoicePeriodFlags) {') ->and($content)->toContain('applyFlagsToPeriodTypes('); diff --git a/services/nginx/app/tests/Unit/ReleaseManager/ReleaseManagerTest.php b/services/nginx/app/tests/Unit/ReleaseManager/ReleaseManagerTest.php index 82b5ad4d..a829ccf0 100644 --- a/services/nginx/app/tests/Unit/ReleaseManager/ReleaseManagerTest.php +++ b/services/nginx/app/tests/Unit/ReleaseManager/ReleaseManagerTest.php @@ -116,10 +116,12 @@ it('requires non-empty release gate checks before auto-sync can proceed', functi 'workflow_url' => 'https://github.com/copenhagentruckwash/api/actions/runs/123', 'required_checks' => [], ], ['slug' => 'stable']); - expect($failed)->toContainEqual(expect()->toMatchArray([ - 'step_key' => 'auto_sync_required_checks', - 'status' => 'failed', - ])); + $failedByStep = array_column($failed, null, 'step_key'); + expect($failedByStep)->toHaveKey('auto_sync_required_checks') + ->and($failedByStep['auto_sync_required_checks'])->toMatchArray([ + 'step_key' => 'auto_sync_required_checks', + 'status' => 'failed', + ]); $passed = $method->invoke($manager, [ 'channel_slug' => 'stable', @@ -130,10 +132,12 @@ it('requires non-empty release gate checks before auto-sync can proceed', functi 'workflow_url' => 'https://github.com/copenhagentruckwash/api/actions/runs/123', 'required_checks' => ['api_gateway'], ], ['slug' => 'stable']); - expect($passed)->toContainEqual(expect()->toMatchArray([ - 'step_key' => 'auto_sync_inputs', - 'status' => 'passed', - ])); + $passedByStep = array_column($passed, null, 'step_key'); + expect($passedByStep)->toHaveKey('auto_sync_inputs') + ->and($passedByStep['auto_sync_inputs'])->toMatchArray([ + 'step_key' => 'auto_sync_inputs', + 'status' => 'passed', + ]); }); it('normalizes GitHub repository identifiers for private repository access checks', function (): void { diff --git a/services/nginx/app/tests/Unit/Selfserve/SelfserveLaneStartRaceLockWiringTest.php b/services/nginx/app/tests/Unit/Selfserve/SelfserveLaneStartRaceLockWiringTest.php index ee91df43..1d131142 100644 --- a/services/nginx/app/tests/Unit/Selfserve/SelfserveLaneStartRaceLockWiringTest.php +++ b/services/nginx/app/tests/Unit/Selfserve/SelfserveLaneStartRaceLockWiringTest.php @@ -9,7 +9,7 @@ it('locks and marks a self-serve start occupied before opening the entrance rela $startCaseOffset = strpos($commandTrait, 'case selfserve_lane_command::START:'); expect($startCaseOffset)->not->toBeFalse(); - $startCase = substr($commandTrait, (int)$startCaseOffset, 3500); + $startCase = substr($commandTrait, (int)$startCaseOffset, 5000); $lockOffset = strpos($startCase, '$start_lock_token = $this->acquireLaneStartCommandLock();'); $occupiedOffset = strpos($startCase, '$this->setLaneStatus(selfserve_lane_status::OCCUPIED);'); $openOffset = strpos($startCase, '$this->openEntrancePortForWashStart();'); diff --git a/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php b/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php index 49217bba..48d4e3d4 100644 --- a/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php +++ b/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php @@ -1386,8 +1386,8 @@ it('applies default caps for wide question trees and reports progress', function ->and($projection['summary']['terminal_path_count'])->toBe(1023) ->and($projection['summary']['outcome_count'])->toBe(2) ->and($projection['summary']['path_sample_count'])->toBe(200) - ->and($projection['progress']['complete'])->toBeTrue() - ->and($projection['progress']['percent'])->toBe(100) + ->and($projection['progress']['complete'])->toBeFalse() + ->and($projection['progress']['percent'])->toBe(99) ->and($projection['paths'])->toHaveCount(200) ->and($projection['paths'][0]['answers'])->toHaveCount(12) ->and($projection['paths'][0]['result'])->toBe('Allowed')