shouldReceive('paginate') ->once() ->with(2, 10, ['order_no' => 'WO']) ->andReturn([ 'data' => [['id' => 9, 'order_no' => 'WO-009', 'work_type_name' => '仓内未发', 'sub_orders' => [], 'form_values' => []]], 'total' => 11, 'page' => 2, 'per_page' => 10, 'last_page' => 2, 'ready' => true, 'sync_status' => ['ready' => true, 'code' => 'ready', 'last_succeeded_at' => '2026-08-31 12:00:00', 'datasets' => []], ]); $this->app->instance(WorkOrderMirrorRepository::class, $repository); $this->loginAs(); $this->withHeaders($this->apiHeaders())->getJson(route('api.ecommerce-finance.work-orders.index', [ 'page' => 2, 'limit' => 10, 'order_no' => 'WO', ])) ->assertOk() ->assertJsonPath('data.0.work_type_name', '仓内未发') ->assertJsonPath('page', 2) ->assertJsonPath('per_page', 10); } public function test_index_exposes_sync_pending_as_503_instead_of_zero_records(): void { $repository = Mockery::mock(WorkOrderMirrorRepository::class); $repository->shouldReceive('paginate')->once()->andReturn([ 'data' => [], 'total' => 0, 'page' => 1, 'per_page' => 25, 'last_page' => 1, 'ready' => false, 'sync_status' => [ 'ready' => false, 'code' => 'initial_sync_pending', 'last_succeeded_at' => null, 'datasets' => [], ], ]); $this->app->instance(WorkOrderMirrorRepository::class, $repository); $this->loginAs(); $this->withHeaders($this->apiHeaders())->getJson(route('api.ecommerce-finance.work-orders.index')) ->assertStatus(503) ->assertJsonPath('ready', false) ->assertJsonPath('sync_status.code', 'initial_sync_pending') ->assertJsonPath('total', 0); } private function apiHeaders(): array { return [ 'Authorization' => 'Basic ' . base64_encode('test@company.com:123456'), ]; } }