toBeTrue(); $ordersCode = preg_replace('/\s+/', ' ', (string)file_get_contents($ordersFile)); expect($ordersCode)->toContain('public function getLastWashTimestampForPlate(string $reg_1): ?string'); // The helper must look at non-deleted orders with non-deleted order items, // matching the contract used by customer_vehicles_o::getLastOrderByPlate(). expect($ordersCode)->toContain("'reg_1' => $normalized_reg_1"); expect($ordersCode)->toContain("'deleted_at' => null"); expect($ordersCode)->toContain("'order_id' => $order_id"); expect($ordersCode)->toContain('return $created_at;'); expect($ordersCode)->toContain('return null;'); }); it('plateScansRoute enriches GET /numberplatescans with last_wash per scan (TRU-78)', function (): void { $routeFile = app_path('routes/plateScansRoute.php'); $ordersFile = app_path('objects/orders_o.php'); expect(is_file($routeFile))->toBeTrue(); expect(is_file($ordersFile))->toBeTrue(); $routeCode = preg_replace('/\s+/', ' ', (string)file_get_contents($routeFile)); $ordersCode = preg_replace('/\s+/', ' ', (string)file_get_contents($ordersFile)); // The route already loads orders_o and customer_vehicles_o; verify the // new enrichment is wired in the GET /numberplatescans handler. expect($routeCode)->toContain("\$this->get('/numberplatescans', function () {"); expect($routeCode)->toContain("'last_wash'"); expect($routeCode)->toContain('getLastWashTimestampForPlate'); expect($routeCode)->toContain("'last_wash' => (new orders_o())->getLastWashTimestampForPlate"); expect($routeCode)->toContain('$tmp_scan_last_wash'); // The helper definition must live in orders_o so the enrichment is real, // not a stub. expect($ordersCode)->toContain('public function getLastWashTimestampForPlate(string $reg_1): ?string'); });