public function testGetGeocodedData() { $mockOne = $this->getMock('Geocoder\\Provider\\ProviderInterface'); $mockOne->expects($this->once())->method('getGeocodedData')->will($this->returnCallback(function () { throw new \Exception(); })); $mockTwo = $this->getMock('Geocoder\\Provider\\ProviderInterface'); $mockTwo->expects($this->once())->method('getGeocodedData')->with('Paris')->will($this->returnValue(array('foo' => 'bar'))); $chain = new ChainProvider(array($mockOne, $mockTwo)); $this->assertEquals(array('foo' => 'bar'), $chain->getGeocodedData('Paris')); }
public function testChainProviderGeocodeThrowsChainNoResultException() { $mockOne = $this->getMock('Geocoder\\Provider\\ProviderInterface'); $mockOne->expects($this->exactly(2))->method('getGeocodedData')->will($this->returnCallback(function () { throw new \Exception(); })); $chain = new ChainProvider(array($mockOne, $mockOne)); try { $chain->getGeocodedData('Paris'); } catch (ChainNoResultException $e) { $this->assertCount(2, $e->getExceptions()); } }