function it_calculates_the_distance_to_another_address(Address $b) { $this->setLatitude(52.3747157); $this->setLongitude(4.8986182); $b->getLatitude()->willReturn(50.8577968); $b->getLongitude()->willReturn(5.7009038); $this->distanceToAddress($b)->shouldReturn(177.583); }
function it_calculates_the_distance_between_two_different_postcodes_in_km(Address $addressA, Address $addressB, Response $a, Response $b) { $postcodeA = '1234AB'; $postcodeB = '5678CD'; $addressA->getLatitude()->willReturn(52.3747157); // Amsterdam (nl) $addressA->getLongitude()->willReturn(4.8986182); $addressA->distanceToAddress($addressB)->willReturn(177.583)->shouldBeCalledTimes(1); $addressB->getLatitude()->willReturn(50.8577968); // Maastricht (nl) $addressB->getLongitude()->willReturn(5.7009038); $a->getAddress()->willReturn($addressA); $b->getAddress()->willReturn($addressB); $this->client->postcode($postcodeA)->willReturn($a)->shouldBeCalledTimes(1); $this->client->postcode($postcodeB)->willReturn($b)->shouldBeCalledTimes(1); $this->getDistanceBetweenPostcodesInKM($postcodeA, $postcodeB)->shouldReturn(177.583); }