Skip to content

Commit 16c2492

Browse files
committed
Add tests for using chain provider instead of single provider
1 parent cbf7956 commit 16c2492

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

tests/Geocoder/Tests/GeocoderFacadeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GeocoderFacadeTest extends TestCase
1919
public function testGeocoderFacade()
2020
{
2121
$this->assertTrue(is_array($providers = \Geocoder::getProviders()));
22-
$this->assertArrayHasKey('free_geo_ip', $providers);
23-
$this->assertInstanceOf('Geocoder\\Provider\\FreeGeoipProvider', $providers['free_geo_ip']);
22+
$this->assertArrayHasKey('chain', $providers);
23+
$this->assertInstanceOf('Geocoder\\Provider\\ChainProvider', $providers['chain']);
2424
}
2525
}

tests/Geocoder/Tests/GeocoderServiceProviderTest.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class GeocoderServiceProviderTest extends TestCase
1818
{
1919
public function testConfig()
2020
{
21-
$this->assertSame('Geocoder\Provider\FreeGeoIpProvider', $this->app['config']->get('geocoder-laravel::provider'));
21+
$this->assertContains('Geocoder\Provider\FreeGeoIpProvider', $this->app['config']->get('geocoder-laravel::providers'));
2222
$this->assertSame('Geocoder\HttpAdapter\CurlHttpAdapter', $this->app['config']->get('geocoder-laravel::adapter'));
2323
}
2424

@@ -35,13 +35,30 @@ public function testGeocoderDefaultAdapter()
3535
$this->assertInstanceOf('Geocoder\\HttpAdapter\\CurlHttpAdapter', $this->app['geocoder.adapter']);
3636
}
3737

38+
public function testGeocoderChainProvider()
39+
{
40+
$this->assertInstanceOf('Geocoder\\Provider\\ChainProvider', $this->app['geocoder.provider']);
41+
}
42+
3843
public function testGeocoderDefaultProvider()
3944
{
40-
$this->assertInstanceOf('Geocoder\\Provider\\FreeGeoIpProvider', $this->app['geocoder.provider']);
45+
$providersArray = $this->getProtectedProperty($this->app['geocoder.provider'], 'providers');
46+
$this->assertInstanceOf('Geocoder\\Provider\\FreeGeoIpProvider', $providersArray[0]);
47+
4148
}
4249

4350
public function testGeocoder()
4451
{
4552
$this->assertInstanceOf('Geocoder\\Geocoder', $this->app['geocoder']);
4653
}
54+
55+
protected function getProtectedProperty($testObj, $propertyName)
56+
{
57+
$reflection = new \ReflectionClass($testObj);
58+
$property = $reflection->getProperty($propertyName);
59+
$property->setAccessible(true);
60+
61+
return $property->getValue($testObj);
62+
}
63+
4764
}

0 commit comments

Comments
 (0)