Skip to content

Commit 299b900

Browse files
committed
fix the way to implode provider's arguments + unit tests
1 parent e70040c commit 299b900

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Toin0u/Geocoder/GeocoderServiceProvider.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ public function register()
5757

5858
foreach($app['config']->get('geocoder-laravel::providers') as $provider => $arguments) {
5959
if (0 !== count($arguments)) {
60-
$providers[] = new $provider($app['geocoder.adapter'], implode(',', $arguments));
60+
$providers[] = call_user_func_array(
61+
function ($arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) use ($app, $provider) {
62+
return new $provider($app['geocoder.adapter'], $arg1, $arg2, $arg3, $arg4);
63+
},
64+
$arguments
65+
);
6166

6267
continue;
6368
}

tests/Geocoder/Tests/GeocoderServiceProviderTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ public function testGeocoderDefaultProvider()
4848
$providers = $this->getProtectedProperty($this->app['geocoder.chain'], 'providers');
4949

5050
$this->assertInstanceOf('Geocoder\\Provider\\GoogleMapsProvider', $providers[0]);
51+
$this->assertSame('fr-FR', $providers[0]->getLocale());
52+
$this->assertInstanceOf('Geocoder\\HttpAdapter\\CurlHttpAdapter', $providers[0]->getAdapter());
53+
5154
$this->assertInstanceOf('Geocoder\\Provider\\FreeGeoIpProvider', $providers[1]);
55+
$this->assertNull($providers[1]->getLocale());
56+
$this->assertInstanceOf('Geocoder\\HttpAdapter\\CurlHttpAdapter', $providers[1]->getAdapter());
5257
}
5358

5459
public function testGeocoder()

0 commit comments

Comments
 (0)