public function test_getLocation_shouldReturnLocationForProviderAndReadFromCacheIfIPIsNotChanged() { $locations = array('pl' => array('city' => 'Wroclaw', 'country_code' => 'pl'), 'nz' => array('city' => 'Wellington', 'country_code' => 'nz')); $poland = $this->getProviderMock(); $poland->expects($this->once())->method('getLocation')->will($this->returnValue($locations['pl'])); $geolocator = new VisitorGeolocator($poland); $geolocator->getLocation(array('ip' => '10.0.0.1')); $nz = $this->getProviderMock(); $nz->expects($this->once())->method('getLocation')->will($this->returnValue($locations['nz'])); $geolocator = new VisitorGeolocator($nz); $geolocator->getLocation(array('ip' => '10.0.0.2')); $this->assertEquals($locations, array('pl' => $geolocator->getLocation(array('ip' => '10.0.0.1')), 'nz' => $geolocator->getLocation(array('ip' => '10.0.0.2')))); }