44
55use Geocoder \Tests \TestCase ;
66use Geocoder \Provider \ChainProvider ;
7+ use Geocoder \Exception \ChainNoResultException ;
78
89/**
910 * @author Markus Bachmann <markus.bachmann@bachi.biz>
@@ -42,6 +43,22 @@ public function testGetReversedData()
4243 $ this ->assertEquals (array ('foo ' => 'bar ' ), $ chain ->getReversedData (array ('11 ' , '22 ' )));
4344 }
4445
46+ public function testChainProviderReverseThrowsChainNoResultException ()
47+ {
48+ $ mockOne = $ this ->getMock ('Geocoder \\Provider \\ProviderInterface ' );
49+ $ mockOne ->expects ($ this ->exactly (2 ))
50+ ->method ('getReversedData ' )
51+ ->will ($ this ->returnCallback (function () { throw new \Exception ; }));
52+
53+ $ chain = new ChainProvider (array ($ mockOne , $ mockOne ));
54+
55+ try {
56+ $ chain ->getReversedData (array ('11 ' , '22 ' ));
57+ } catch (ChainNoResultException $ e ) {
58+ $ this ->assertCount (2 , $ e ->getExceptions ());
59+ }
60+ }
61+
4562 public function testGetGeocodedData ()
4663 {
4764 $ mockOne = $ this ->getMock ('Geocoder \\Provider \\ProviderInterface ' );
@@ -59,4 +76,20 @@ public function testGetGeocodedData()
5976
6077 $ this ->assertEquals (array ('foo ' => 'bar ' ), $ chain ->getGeocodedData ('Paris ' ));
6178 }
79+
80+ public function testChainProviderGeocodeThrowsChainNoResultException ()
81+ {
82+ $ mockOne = $ this ->getMock ('Geocoder \\Provider \\ProviderInterface ' );
83+ $ mockOne ->expects ($ this ->exactly (2 ))
84+ ->method ('getGeocodedData ' )
85+ ->will ($ this ->returnCallback (function () { throw new \Exception ; }));
86+
87+ $ chain = new ChainProvider (array ($ mockOne , $ mockOne ));
88+
89+ try {
90+ $ chain ->getGeocodedData ('Paris ' );
91+ } catch (ChainNoResultException $ e ) {
92+ $ this ->assertCount (2 , $ e ->getExceptions ());
93+ }
94+ }
6295}
0 commit comments