shouldReceive('get') ->once() ->with('/orders', Mockery::on(function (array $payload) { return $payload['filter[customer_id]'] === 'ctm_123' && $payload['sort'] === '-created_at'; })) ->andReturn(['data' => [], 'meta' => []]); $this->app->instance(LemonSqueezyClient::class, $client); $service = $this->app->make(LemonSqueezyOrderService::class); $service->listForCustomer('ctm_123'); $this->assertTrue(true); } public function test_find_by_checkout_id_uses_checkout_then_order_lookup(): void { $client = Mockery::mock(LemonSqueezyClient::class); $client->shouldReceive('get') ->once() ->with('/checkouts/chk_123', []) ->andReturn(['data' => ['attributes' => ['order_id' => 'ord_123']]]); $client->shouldReceive('get') ->once() ->with('/orders/ord_123', []) ->andReturn(['data' => ['id' => 'ord_123', 'attributes' => ['status' => 'paid']]]); $this->app->instance(LemonSqueezyClient::class, $client); $service = $this->app->make(LemonSqueezyOrderService::class); $order = $service->findByCheckoutId('chk_123'); $this->assertIsArray($order); $this->assertSame('ord_123', $order['id'] ?? null); } }