/** * @param $postalCode * @param $houseNumber * @throws \LogicException * @return Address */ public function getAddressByPostalcodeAndHouseNumber($postalCode, $houseNumber) { $response = $this->client->address($postalCode, $houseNumber); if (!$response instanceof Response) { throw new \LogicException('Client::address should return instanceof Response'); } return $this->getAddressFromResponse($response); }
function it_should_return_address_information_by_given_postalcode_and_housenumber(Response $response, Address $address) { $address->getStreet()->willReturn('Wilhelminapark'); $address->getHouseNumber('21')->willReturn('21'); $address->getPostcode()->willReturn('5041EB'); $address->getTown()->willReturn('Tilburg'); $address->getLatitude()->willReturn(51.9401); $address->getLongitude()->willReturn(5.61531); $response->getAddress()->willReturn($address); $this->client->address('5041EB', '21')->willReturn($response); $this->getAddressByPostalcodeAndHouseNumber('5041EB', '21')->shouldReturnAnInstanceOf('Niborb\\PostcodeAPI\\Address'); $this->getAddressByPostalcodeAndHouseNumber('5041EB', '21')->shouldReturn($address); $this->client->address('5041EB', '21')->shouldBeCalledTimes(2); }