Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Commit 2796400

Browse files
committed
fix tests
1 parent efbb25d commit 2796400

6 files changed

+27
-11
lines changed

src/GeoCoder.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function init()
4040

4141
/**
4242
* Sets the service to use for geocoding
43+
*
4344
* @param BaseService $service
4445
*/
4546
public function setService(BaseService $service)
@@ -66,8 +67,11 @@ public function getPluginName()
6667

6768
/**
6869
* Registers plugin asset bundle
70+
*
6971
* @param \yii\web\View $view
70-
* @return mixed
72+
*
73+
* @return $this
74+
* @codeCoverageIgnore
7175
*/
7276
public function registerAssetBundle($view)
7377
{
@@ -83,9 +87,12 @@ public function registerAssetBundle($view)
8387
public function encode()
8488
{
8589

86-
$this->clientOptions = ArrayHelper::merge([
87-
'showMarker' => true
88-
], $this->clientOptions);
90+
$this->clientOptions = ArrayHelper::merge(
91+
[
92+
'showMarker' => true
93+
],
94+
$this->clientOptions
95+
);
8996

9097
$this->clientOptions['geocoder'] = $this->getService()->getJs();
9198

src/ServiceBing.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function init()
3636

3737
/**
3838
* @inheritdoc
39+
* @codeCoverageIgnore
3940
*/
4041
public function registerAssetBundle($view)
4142
{

src/ServiceMapQuest.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function init()
3636

3737
/**
3838
* @inheritdoc
39+
* @codeCoverageIgnore
3940
*/
4041
public function registerAssetBundle($view)
4142
{

src/ServiceNominatim.php

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ServiceNominatim extends BaseService
3535

3636
/**
3737
* @inheritdoc
38+
* @codeCoverageIgnore
3839
*/
3940
public function registerAssetBundle($view)
4041
{

tests/functional/GeoCoderTest.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,44 @@
1010

1111
class GeoCoderTest extends TestCase
1212
{
13-
public function testNominatimEncode() {
13+
public function testNominatim() {
1414
$nominatim = new ServiceNominatim();
1515
$geocoder = new GeoCoder([
16+
'name' => 'testName',
1617
'service' => $nominatim
1718
]);
1819
$this->assertEquals($nominatim, $geocoder->getService());
1920
$content = $geocoder->encode();
20-
file_put_contents(__DIR__ . '/data/service.nominatim.bin', $content);
21+
2122
$this->assertEquals('plugin:geocoder', $geocoder->getPluginName());
2223
$this->assertEquals(file_get_contents(__DIR__ . '/data/service.nominatim.bin'), $content);
2324
}
2425

25-
public function testBingEncode() {
26+
public function testBing() {
2627
$bing = new ServiceBing(['key' => 'bogus-key']);
2728
$geocoder = new GeoCoder([
2829
'service' => $bing
2930
]);
3031
$this->assertEquals($bing, $geocoder->getService());
3132
$content = $geocoder->encode();
32-
file_put_contents(__DIR__ . '/data/service.bing.bin', $content);
33+
3334
$this->assertEquals(file_get_contents(__DIR__ . '/data/service.bing.bin'), $content);
35+
$this->setExpectedException('yii\base\InvalidConfigException');
36+
$quest = new ServiceBing();
3437
}
3538

36-
public function testMapQuestEncode() {
39+
public function testMapQuest() {
3740
$quest = new ServiceMapQuest(['key' => 'bogus-key']);
3841
$geocoder = new GeoCoder([
3942
'service' => $quest
4043
]);
4144
$this->assertEquals($quest, $geocoder->getService());
4245
$content = $geocoder->encode();
43-
file_put_contents(__DIR__ . '/data/service.mapquest.bin', $content);
46+
4447
$this->assertEquals(file_get_contents(__DIR__ . '/data/service.mapquest.bin'), $content);
48+
49+
$this->setExpectedException('yii\base\InvalidConfigException');
50+
$quest = new ServiceMapQuest();
4551
}
4652

4753
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
new L.Control.Geocoder({"showMarker":true,"geocoder":L.Control.Geocoder.nominatim({"serviceUrl":"http://nominatim.openstreetmap.org/","geocodingQueryParams":"{}","reverseQueryParams":"{}"})}).addTo()
1+
var testName = new L.Control.Geocoder({"showMarker":true,"geocoder":L.Control.Geocoder.nominatim({"serviceUrl":"http://nominatim.openstreetmap.org/","geocodingQueryParams":"{}","reverseQueryParams":"{}"})}).addTo();

0 commit comments

Comments
 (0)