jsonResponse([ 'meta' => ['hotel_id' => 163113, 'count' => 3, 'execution_time_ms' => 3], 'data' => [ ['room_type_id' => 27, 'pool_room_type_id' => 27], ['room_type_id' => 2366, 'pool_room_type_id' => 2366], ['room_type_id' => 2367, 'pool_room_type_id' => 2366], ], ]); }); $pools = $this->client($http)->getContingentPools(163113); self::assertSame([['GET', 'https://bpn-connect.test/api/v1/rooms/contingent-pools?hotelId=163113']], $requests); self::assertSame([27 => 27, 2366 => 2366, 2367 => 2366], $pools); } public function testAnUnknownHotelYieldsNoPools(): void { $http = new MockHttpClient($this->jsonResponse(['meta' => ['hotel_id' => 1, 'count' => 0], 'data' => []])); self::assertSame([], $this->client($http)->getContingentPools(1)); } public function testAFailedRequestThrows(): void { $http = new MockHttpClient(new MockResponse('', ['http_code' => 500])); $this->expectException(BpnConnectException::class); $this->client($http)->getContingentPools(163113); } /** * @param array $payload */ private function jsonResponse(array $payload): MockResponse { return new MockResponse(json_encode($payload, JSON_THROW_ON_ERROR), [ 'response_headers' => ['content-type' => 'application/json'], ]); } private function client(MockHttpClient $http): RoomsClient { return new RoomsClient($http, new NullLogger(), 'https://bpn-connect.test', 'secret'); } }