Skip to content

Commit a5a908d

Browse files
committed
Fix up default merging.
1 parent 56562d6 commit a5a908d

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"autoload": {
2828
"psr-4": {
2929
"Geo\\": "src",
30-
"Geo\\Test\\Fixture\\": "tests\\Fixture"
30+
"Geo\\Test\\Fixture\\": "tests/Fixture"
3131
}
3232
},
3333
"autoload-dev": {
@@ -38,6 +38,7 @@
3838
}
3939
},
4040
"scripts": {
41+
"setup": "[ ! -f phpunit.phar ] && wget https://phar.phpunit.de/phpunit.phar",
4142
"test": "php phpunit.phar",
4243
"coverage": "php phpunit.phar --log-junit webroot/coverage/unitreport.xml --coverage-html webroot/coverage --coverage-clover webroot/coverage/coverage.xml",
4344
"cs-check": "phpcs -p --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --ignore=/vendor/,/tmp/,/logs/,/config/Migrations/ --extensions=php ./",

src/View/Helper/GoogleMapHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class GoogleMapHelper extends Helper {
2626

2727
use JsBaseEngineTrait;
2828

29+
const API = 'maps.google.com/maps/api/js?';
30+
31+
const STATIC_API = 'maps.google.com/maps/api/staticmap?';
32+
2933
/**
3034
* @var int
3135
*/
@@ -51,10 +55,6 @@ class GoogleMapHelper extends Helper {
5155
*/
5256
public static $infoContentCount = 0;
5357

54-
const API = 'maps.google.com/maps/api/js?';
55-
56-
const STATIC_API = 'maps.google.com/maps/api/staticmap?';
57-
5858
const TYPE_ROADMAP = 'R';
5959

6060
const TYPE_HYBRID = 'H';
@@ -252,7 +252,7 @@ class GoogleMapHelper extends Helper {
252252
* @param array $config
253253
*/
254254
public function __construct($View = null, $config = []) {
255-
$google = (array)Configure::read('GoogleMap');
255+
$google = $config + (array)Configure::read('GoogleMap');
256256
$defaults = $this->_defaultOptions;
257257
if (!empty($google['api'])) {
258258
$defaults['map']['api'] = $google['api'];

tests/TestCase/View/Helper/GoogleMapHelperTest.php

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*/
1111
class GoogleMapHelperTest extends TestCase {
1212

13+
/**
14+
* @return void
15+
*/
1316
public function setUp() {
1417
parent::setUp();
1518

@@ -19,13 +22,22 @@ public function setUp() {
1922
$this->GoogleMap = new GoogleMapHelper($this->View);
2023
}
2124

22-
public function testObject() {
23-
$this->assertInstanceOf('Geo\View\Helper\GoogleMapHelper', $this->GoogleMap);
25+
/**
26+
* @return void
27+
*/
28+
public function testConfigMergeDefaults() {
29+
$config = [
30+
'zoom' => 2,
31+
'type' => 'foo'
32+
];
33+
$this->GoogleMap = new GoogleMapHelper($this->View, $config);
34+
35+
$result = $this->GoogleMap->config();
36+
$this->assertEquals('foo', $result['map']['type']);
37+
$this->assertEquals(2, $result['map']['zoom']);
2438
}
2539

2640
/**
27-
* GoogleMapHelperTest::testConfigMerge()
28-
*
2941
* @return void
3042
*/
3143
public function testConfigMerge() {
@@ -42,6 +54,9 @@ public function testConfigMerge() {
4254
$this->assertEquals(8, $result['map']['zoom']);
4355
}
4456

57+
/**
58+
* @return void
59+
*/
4560
public function testMapUrl() {
4661
$url = $this->GoogleMap->mapUrl(['to' => 'Munich, Germany']);
4762
$this->assertEquals('http://maps.google.com/maps?daddr=Munich%2C+Germany', $url);
@@ -50,13 +65,19 @@ public function testMapUrl() {
5065
$this->assertEquals('http://maps.google.com/maps?daddr=%3CM%C3%BCnchen%3E%2C+Germany', $url);
5166
}
5267

68+
/**
69+
* @return void
70+
*/
5371
public function testMapLink() {
5472
$result = $this->GoogleMap->mapLink('<To Munich>!', ['to' => '<Munich>, Germany']);
5573
$expected = '<a href="http://maps.google.com/maps?daddr=%3CMunich%3E%2C+Germany">&lt;To Munich&gt;!</a>';
5674
//echo $result;
5775
$this->assertEquals($expected, $result);
5876
}
5977

78+
/**
79+
* @return void
80+
*/
6081
public function testLinkWithMapUrl() {
6182
$url = $this->GoogleMap->mapUrl(['to' => '<München>, Germany']);
6283
$result = $this->GoogleMap->Html->link('Some title', $url);
@@ -65,6 +86,9 @@ public function testLinkWithMapUrl() {
6586
$this->assertEquals($expected, $result);
6687
}
6788

89+
/**
90+
* @return void
91+
*/
6892
public function testStaticPaths() {
6993
$m = [
7094
[
@@ -82,18 +106,18 @@ public function testStaticPaths() {
82106
];
83107

84108
$is = $this->GoogleMap->staticPaths($m);
85-
//echo pr(h($is));
86109

87110
$options = [
88111
'paths' => $is
89112
];
90113
$is = $this->GoogleMap->staticMapLink('My Title', $options);
91-
//echo h($is).BR.BR;
92114

93115
$is = $this->GoogleMap->staticMap($options);
94-
//echo $is;
95116
}
96117

118+
/**
119+
* @return void
120+
*/
97121
public function testStaticMarkers() {
98122
$m = $this->markerElements = [
99123
[
@@ -117,6 +141,9 @@ public function testStaticMarkers() {
117141
// http://maps.google.com/staticmap?size=500x500&maptype=hybrid&markers=color:red|label:S|48.3,11.2&sensor=false
118142
// http://maps.google.com/maps/api/staticmap?size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false
119143

144+
/**
145+
* @return void
146+
*/
120147
public function testStatic() {
121148
//echo '<h2>StaticMap</h2>';
122149
$m = [
@@ -193,6 +220,9 @@ public function testStatic() {
193220
//echo $link;
194221
}
195222

223+
/**
224+
* @return void
225+
*/
196226
public function testStaticMapWithStaticMapLink() {
197227
//echo '<h2>testStaticMapWithStaticMapLink</h2>';
198228
$markers = [];
@@ -203,6 +233,9 @@ public function testStaticMapWithStaticMapLink() {
203233
//echo $this->GoogleMap->Html->link('Open Static Map', $staticMapUrl, array('class'=>'staticMap', 'title'=>__d('tools', 'click for full map'))); //, 'escape'=>false
204234
}
205235

236+
/**
237+
* @return void
238+
*/
206239
public function testMarkerIcons() {
207240
$tests = [
208241
['green', null],
@@ -352,6 +385,9 @@ public function testDynamic2() {
352385
//echo '<a href="javascript:void(0)" class="mapAnchor" rel="m3">Marker3</a>';
353386
}
354387

388+
/**
389+
* @return void
390+
*/
355391
public function testDynamic3() {
356392
//echo '<h2>Map with Directions</h2>';
357393
$options = [

0 commit comments

Comments
 (0)