1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Google Map bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\GoogleMapBundle\Tests\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Http\Client\HttpClient; |
15
|
|
|
use Http\Message\MessageFactory; |
16
|
|
|
use Ivory\GoogleMap\Helper\ApiHelper; |
17
|
|
|
use Ivory\GoogleMap\Helper\Formatter\Formatter; |
18
|
|
|
use Ivory\GoogleMap\Helper\MapHelper; |
19
|
|
|
use Ivory\GoogleMap\Helper\PlaceAutocompleteHelper; |
20
|
|
|
use Ivory\GoogleMap\Service\Directions\Directions; |
21
|
|
|
use Ivory\GoogleMap\Service\DistanceMatrix\DistanceMatrix; |
22
|
|
|
use Ivory\GoogleMap\Service\Elevation\Elevation; |
23
|
|
|
use Ivory\GoogleMap\Service\Geocoder\GeocoderProvider; |
24
|
|
|
use Ivory\GoogleMap\Service\TimeZone\TimeZone; |
25
|
|
|
use Ivory\GoogleMapBundle\DependencyInjection\IvoryGoogleMapExtension; |
26
|
|
|
use Ivory\GoogleMapBundle\IvoryGoogleMapBundle; |
27
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
28
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @author GeLo <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
abstract class AbstractIvoryGoogleMapExtensionTest extends \PHPUnit_Framework_TestCase |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @var ContainerBuilder |
37
|
|
|
*/ |
38
|
|
|
private $container; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var bool |
42
|
|
|
*/ |
43
|
|
|
private $debug; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
private $locale; |
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var HttpClient|\PHPUnit_Framework_MockObject_MockObject |
52
|
|
|
*/ |
53
|
|
|
private $client; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var MessageFactory|\PHPUnit_Framework_MockObject_MockObject |
57
|
|
|
*/ |
58
|
|
|
private $messageFactory; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
protected function setUp() |
64
|
|
|
{ |
65
|
|
|
$this->container = new ContainerBuilder(); |
66
|
|
|
$this->container->setParameter('kernel.debug', $this->debug = false); |
67
|
|
|
$this->container->setParameter('locale', $this->locale = 'en'); |
68
|
|
|
$this->container->set('httplug.client', $this->client = $this->createClientMock()); |
69
|
|
|
$this->container->set('httplug.message_factory', $this->messageFactory = $this->createMessageFactoryMock()); |
70
|
|
|
$this->container->registerExtension($extension = new IvoryGoogleMapExtension()); |
71
|
|
|
$this->container->loadFromExtension($extension->getAlias()); |
72
|
|
|
(new IvoryGoogleMapBundle())->build($this->container); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param ContainerBuilder $container |
77
|
|
|
* @param string $configuration |
78
|
|
|
*/ |
79
|
|
|
abstract protected function loadConfiguration(ContainerBuilder $container, $configuration); |
80
|
|
|
|
81
|
|
|
public function testDefaultState() |
82
|
|
|
{ |
83
|
|
|
$this->container->compile(); |
84
|
|
|
|
85
|
|
|
$apiHelper = $this->container->get('ivory.google_map.helper.api'); |
86
|
|
|
$mapHelper = $this->container->get('ivory.google_map.helper.map'); |
87
|
|
|
$placeAutocompleteHelper = $this->container->get('ivory.google_map.helper.place_autocomplete'); |
88
|
|
|
|
89
|
|
|
$this->assertInstanceOf(ApiHelper::class, $apiHelper); |
90
|
|
|
$this->assertInstanceOf(MapHelper::class, $mapHelper); |
91
|
|
|
$this->assertInstanceOf(PlaceAutocompleteHelper::class, $placeAutocompleteHelper); |
92
|
|
|
|
93
|
|
|
$formatter = $this->container->get('ivory.google_map.helper.formatter'); |
94
|
|
|
$loaderRenderer = $this->container->get('ivory.google_map.helper.renderer.loader');; |
95
|
|
|
|
96
|
|
|
$this->assertSame($this->debug, $formatter->isDebug()); |
97
|
|
|
$this->assertSame($this->locale, $loaderRenderer->getLanguage()); |
98
|
|
|
$this->assertFalse($loaderRenderer->hasKey()); |
99
|
|
|
|
100
|
|
|
$this->assertTrue($this->container->get('ivory.google_map.helper.renderer.control.manager')->hasRenderers()); |
101
|
|
|
$this->assertTrue($this->container->get('ivory.google_map.helper.renderer.overlay.extendable')->hasRenderers()); |
102
|
|
|
$this->assertTrue($this->container->get('ivory.google_map.helper.event_dispatcher')->hasListeners()); |
103
|
|
|
|
104
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.directions')); |
105
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.distance_matrix')); |
106
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.elevation')); |
107
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.geocoder')); |
108
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.time_zone')); |
109
|
|
|
|
110
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.templating.api')); |
111
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.templating.map')); |
112
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.templating.place_autocomplete')); |
113
|
|
|
|
114
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.twig.extension.api')); |
115
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.twig.extension.map')); |
116
|
|
|
$this->assertFalse($this->container->has('ivory.google_map.twig.extension.place_autocomplete')); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
View Code Duplication |
public function testTemplatingHelpers() |
|
|
|
|
120
|
|
|
{ |
121
|
|
|
$this->container->setDefinition('templating.engine.php', new Definition(\stdClass::class)); |
122
|
|
|
$this->container->compile(); |
123
|
|
|
|
124
|
|
|
$this->assertTrue($this->container->has('ivory.google_map.templating.api')); |
125
|
|
|
$this->assertTrue($this->container->has('ivory.google_map.templating.map')); |
126
|
|
|
$this->assertTrue($this->container->has('ivory.google_map.templating.place_autocomplete')); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
View Code Duplication |
public function testTwigExtensions() |
|
|
|
|
130
|
|
|
{ |
131
|
|
|
$this->container->setDefinition('twig', new Definition(\stdClass::class)); |
132
|
|
|
$this->container->compile(); |
133
|
|
|
|
134
|
|
|
$this->assertTrue($this->container->has('ivory.google_map.twig.extension.api')); |
135
|
|
|
$this->assertTrue($this->container->has('ivory.google_map.twig.extension.map')); |
136
|
|
|
$this->assertTrue($this->container->has('ivory.google_map.twig.extension.place_autocomplete')); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
View Code Duplication |
public function testTemplatingFormResources() |
|
|
|
|
140
|
|
|
{ |
141
|
|
|
$this->container->setParameter($parameter = 'templating.helper.form.resources', $resources = ['resource']); |
142
|
|
|
$this->container->compile(); |
143
|
|
|
|
144
|
|
|
$this->assertSame( |
145
|
|
|
array_merge(['IvoryGoogleMapBundle:Form'], $resources), |
146
|
|
|
$this->container->getParameter($parameter) |
147
|
|
|
); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
View Code Duplication |
public function testTwigFormResources() |
|
|
|
|
151
|
|
|
{ |
152
|
|
|
$this->container->setParameter($parameter = 'twig.form.resources', $resources = ['resource']); |
153
|
|
|
$this->container->compile(); |
154
|
|
|
|
155
|
|
|
$this->assertSame( |
156
|
|
|
array_merge(['IvoryGoogleMapBundle:Form:place_autocomplete_widget.html.twig'], $resources), |
157
|
|
|
$this->container->getParameter($parameter) |
158
|
|
|
); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function testFormatterDebug() |
162
|
|
|
{ |
163
|
|
|
$this->loadConfiguration($this->container, 'debug'); |
164
|
|
|
$this->container->compile(); |
165
|
|
|
|
166
|
|
|
$this->assertTrue($this->container->get('ivory.google_map.helper.formatter')->isDebug()); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
View Code Duplication |
public function testMapLanguage() |
|
|
|
|
170
|
|
|
{ |
171
|
|
|
$this->loadConfiguration($this->container, 'language'); |
172
|
|
|
$this->container->compile(); |
173
|
|
|
|
174
|
|
|
$this->assertSame('fr', $this->container->get('ivory.google_map.helper.renderer.loader')->getLanguage()); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
View Code Duplication |
public function testMapApiKey() |
|
|
|
|
178
|
|
|
{ |
179
|
|
|
$this->loadConfiguration($this->container, 'api_key'); |
180
|
|
|
$this->container->compile(); |
181
|
|
|
|
182
|
|
|
$this->assertSame('key', $this->container->get('ivory.google_map.helper.renderer.loader')->getKey()); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
View Code Duplication |
public function testDirections() |
|
|
|
|
186
|
|
|
{ |
187
|
|
|
$this->loadConfiguration($this->container, 'directions'); |
188
|
|
|
$this->container->compile(); |
189
|
|
|
|
190
|
|
|
$directions = $this->container->get('ivory.google_map.directions'); |
191
|
|
|
|
192
|
|
|
$this->assertInstanceOf(Directions::class, $directions); |
193
|
|
|
$this->assertSame($this->client, $directions->getClient()); |
194
|
|
|
$this->assertSame($this->messageFactory, $directions->getMessageFactory()); |
195
|
|
|
$this->assertTrue($directions->isHttps()); |
196
|
|
|
$this->assertSame(Directions::FORMAT_JSON, $directions->getFormat()); |
197
|
|
|
$this->assertFalse($directions->hasBusinessAccount()); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
public function testDirectionsHttps() |
201
|
|
|
{ |
202
|
|
|
$this->loadConfiguration($this->container, 'directions_https'); |
203
|
|
|
$this->container->compile(); |
204
|
|
|
|
205
|
|
|
$this->assertFalse($this->container->get('ivory.google_map.directions')->isHttps()); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
View Code Duplication |
public function testDirectionsFormat() |
|
|
|
|
209
|
|
|
{ |
210
|
|
|
$this->loadConfiguration($this->container, 'directions_format'); |
211
|
|
|
$this->container->compile(); |
212
|
|
|
|
213
|
|
|
$this->assertSame(Directions::FORMAT_XML, $this->container->get('ivory.google_map.directions')->getFormat()); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
View Code Duplication |
public function testDirectionsApiKey() |
|
|
|
|
217
|
|
|
{ |
218
|
|
|
$this->loadConfiguration($this->container, 'directions_api_key'); |
219
|
|
|
$this->container->compile(); |
220
|
|
|
|
221
|
|
|
$this->assertSame('key', $this->container->get('ivory.google_map.directions')->getKey()); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
View Code Duplication |
public function testDirectionsBusinessAccount() |
|
|
|
|
225
|
|
|
{ |
226
|
|
|
$this->loadConfiguration($this->container, 'directions_business_account'); |
227
|
|
|
$this->container->compile(); |
228
|
|
|
|
229
|
|
|
$directions = $this->container->get('ivory.google_map.directions'); |
230
|
|
|
|
231
|
|
|
$this->assertTrue($directions->hasBusinessAccount()); |
232
|
|
|
$this->assertSame('my-client', $directions->getBusinessAccount()->getClientId()); |
233
|
|
|
$this->assertSame('my-secret', $directions->getBusinessAccount()->getSecret()); |
234
|
|
|
$this->assertFalse($directions->getBusinessAccount()->hasChannel()); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
View Code Duplication |
public function testDirectionsBusinessAccountChannel() |
|
|
|
|
238
|
|
|
{ |
239
|
|
|
$this->loadConfiguration($this->container, 'directions_business_account_channel'); |
240
|
|
|
$this->container->compile(); |
241
|
|
|
|
242
|
|
|
$directions = $this->container->get('ivory.google_map.directions'); |
243
|
|
|
|
244
|
|
|
$this->assertTrue($directions->hasBusinessAccount()); |
245
|
|
|
$this->assertSame('my-client', $directions->getBusinessAccount()->getClientId()); |
246
|
|
|
$this->assertSame('my-secret', $directions->getBusinessAccount()->getSecret()); |
247
|
|
|
$this->assertSame('my-channel', $directions->getBusinessAccount()->getChannel()); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
252
|
|
|
*/ |
253
|
|
|
public function testDirectionsBusinessAccountInvalid() |
254
|
|
|
{ |
255
|
|
|
$this->loadConfiguration($this->container, 'directions_business_account_invalid'); |
256
|
|
|
$this->container->compile(); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
261
|
|
|
*/ |
262
|
|
|
public function testDirectionsInvalid() |
263
|
|
|
{ |
264
|
|
|
$this->loadConfiguration($this->container, 'directions_invalid'); |
265
|
|
|
$this->container->compile(); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
View Code Duplication |
public function testDistanceMatrix() |
|
|
|
|
269
|
|
|
{ |
270
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix'); |
271
|
|
|
$this->container->compile(); |
272
|
|
|
|
273
|
|
|
$distanceMatrix = $this->container->get('ivory.google_map.distance_matrix'); |
274
|
|
|
|
275
|
|
|
$this->assertInstanceOf(DistanceMatrix::class, $distanceMatrix); |
276
|
|
|
$this->assertSame($this->client, $distanceMatrix->getClient()); |
277
|
|
|
$this->assertSame($this->messageFactory, $distanceMatrix->getMessageFactory()); |
278
|
|
|
$this->assertTrue($distanceMatrix->isHttps()); |
279
|
|
|
$this->assertSame(DistanceMatrix::FORMAT_JSON, $distanceMatrix->getFormat()); |
280
|
|
|
$this->assertFalse($distanceMatrix->hasBusinessAccount()); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
public function testDistanceMatrixHttps() |
284
|
|
|
{ |
285
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_https'); |
286
|
|
|
$this->container->compile(); |
287
|
|
|
|
288
|
|
|
$this->assertFalse($this->container->get('ivory.google_map.distance_matrix')->isHttps()); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
View Code Duplication |
public function testDistanceMatrixFormat() |
|
|
|
|
292
|
|
|
{ |
293
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_format'); |
294
|
|
|
$this->container->compile(); |
295
|
|
|
|
296
|
|
|
$this->assertSame( |
297
|
|
|
DistanceMatrix::FORMAT_XML, |
298
|
|
|
$this->container->get('ivory.google_map.distance_matrix')->getFormat() |
299
|
|
|
); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
View Code Duplication |
public function testDistanceMatrixApiKey() |
|
|
|
|
303
|
|
|
{ |
304
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_api_key'); |
305
|
|
|
$this->container->compile(); |
306
|
|
|
|
307
|
|
|
$this->assertSame('key', $this->container->get('ivory.google_map.distance_matrix')->getKey()); |
308
|
|
|
} |
309
|
|
|
|
310
|
|
View Code Duplication |
public function testDistanceMatrixBusinessAccount() |
|
|
|
|
311
|
|
|
{ |
312
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_business_account'); |
313
|
|
|
$this->container->compile(); |
314
|
|
|
|
315
|
|
|
$distanceMatrix = $this->container->get('ivory.google_map.distance_matrix'); |
316
|
|
|
|
317
|
|
|
$this->assertTrue($distanceMatrix->hasBusinessAccount()); |
318
|
|
|
$this->assertSame('my-client', $distanceMatrix->getBusinessAccount()->getClientId()); |
319
|
|
|
$this->assertSame('my-secret', $distanceMatrix->getBusinessAccount()->getSecret()); |
320
|
|
|
$this->assertFalse($distanceMatrix->getBusinessAccount()->hasChannel()); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
View Code Duplication |
public function testDistanceMatrixBusinessAccountChannel() |
|
|
|
|
324
|
|
|
{ |
325
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_business_account_channel'); |
326
|
|
|
$this->container->compile(); |
327
|
|
|
|
328
|
|
|
$distanceMatrix = $this->container->get('ivory.google_map.distance_matrix'); |
329
|
|
|
|
330
|
|
|
$this->assertTrue($distanceMatrix->hasBusinessAccount()); |
331
|
|
|
$this->assertSame('my-client', $distanceMatrix->getBusinessAccount()->getClientId()); |
332
|
|
|
$this->assertSame('my-secret', $distanceMatrix->getBusinessAccount()->getSecret()); |
333
|
|
|
$this->assertSame('my-channel', $distanceMatrix->getBusinessAccount()->getChannel()); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
338
|
|
|
*/ |
339
|
|
|
public function testDistanceMatrixBusinessAccountInvalid() |
340
|
|
|
{ |
341
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_business_account_invalid'); |
342
|
|
|
$this->container->compile(); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
347
|
|
|
*/ |
348
|
|
|
public function testDistanceMatrixInvalid() |
349
|
|
|
{ |
350
|
|
|
$this->loadConfiguration($this->container, 'distance_matrix_invalid'); |
351
|
|
|
$this->container->compile(); |
352
|
|
|
} |
353
|
|
|
|
354
|
|
View Code Duplication |
public function testElevation() |
|
|
|
|
355
|
|
|
{ |
356
|
|
|
$this->loadConfiguration($this->container, 'elevation'); |
357
|
|
|
$this->container->compile(); |
358
|
|
|
|
359
|
|
|
$elevation = $this->container->get('ivory.google_map.elevation'); |
360
|
|
|
|
361
|
|
|
$this->assertInstanceOf(Elevation::class, $elevation); |
362
|
|
|
$this->assertSame($this->client, $elevation->getClient()); |
363
|
|
|
$this->assertSame($this->messageFactory, $elevation->getMessageFactory()); |
364
|
|
|
$this->assertTrue($elevation->isHttps()); |
365
|
|
|
$this->assertSame(Elevation::FORMAT_JSON, $elevation->getFormat()); |
366
|
|
|
$this->assertFalse($elevation->hasBusinessAccount()); |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
public function testElevationHttps() |
370
|
|
|
{ |
371
|
|
|
$this->loadConfiguration($this->container, 'elevation_https'); |
372
|
|
|
$this->container->compile(); |
373
|
|
|
|
374
|
|
|
$this->assertFalse($this->container->get('ivory.google_map.elevation')->isHttps()); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
public function testElevationFormat() |
378
|
|
|
{ |
379
|
|
|
$this->loadConfiguration($this->container, 'elevation_format'); |
380
|
|
|
$this->container->compile(); |
381
|
|
|
|
382
|
|
|
$this->assertSame(Elevation::FORMAT_XML, $this->container->get('ivory.google_map.elevation')->getFormat()); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
View Code Duplication |
public function testElevationApiKey() |
|
|
|
|
386
|
|
|
{ |
387
|
|
|
$this->loadConfiguration($this->container, 'elevation_api_key'); |
388
|
|
|
$this->container->compile(); |
389
|
|
|
|
390
|
|
|
$this->assertSame('key', $this->container->get('ivory.google_map.elevation')->getKey()); |
391
|
|
|
} |
392
|
|
|
|
393
|
|
View Code Duplication |
public function testElevationBusinessAccount() |
|
|
|
|
394
|
|
|
{ |
395
|
|
|
$this->loadConfiguration($this->container, 'elevation_business_account'); |
396
|
|
|
$this->container->compile(); |
397
|
|
|
|
398
|
|
|
$elevation = $this->container->get('ivory.google_map.elevation'); |
399
|
|
|
|
400
|
|
|
$this->assertTrue($elevation->hasBusinessAccount()); |
401
|
|
|
$this->assertSame('my-client', $elevation->getBusinessAccount()->getClientId()); |
402
|
|
|
$this->assertSame('my-secret', $elevation->getBusinessAccount()->getSecret()); |
403
|
|
|
$this->assertFalse($elevation->getBusinessAccount()->hasChannel()); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
View Code Duplication |
public function testElevationBusinessAccountChannel() |
|
|
|
|
407
|
|
|
{ |
408
|
|
|
$this->loadConfiguration($this->container, 'elevation_business_account_channel'); |
409
|
|
|
$this->container->compile(); |
410
|
|
|
|
411
|
|
|
$elevation = $this->container->get('ivory.google_map.elevation'); |
412
|
|
|
|
413
|
|
|
$this->assertTrue($elevation->hasBusinessAccount()); |
414
|
|
|
$this->assertSame('my-client', $elevation->getBusinessAccount()->getClientId()); |
415
|
|
|
$this->assertSame('my-secret', $elevation->getBusinessAccount()->getSecret()); |
416
|
|
|
$this->assertSame('my-channel', $elevation->getBusinessAccount()->getChannel()); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
421
|
|
|
*/ |
422
|
|
|
public function testElevationBusinessAccountInvalid() |
423
|
|
|
{ |
424
|
|
|
$this->loadConfiguration($this->container, 'elevation_business_account_invalid'); |
425
|
|
|
$this->container->compile(); |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
430
|
|
|
*/ |
431
|
|
|
public function testElevationInvalid() |
432
|
|
|
{ |
433
|
|
|
$this->loadConfiguration($this->container, 'elevation_invalid'); |
434
|
|
|
$this->container->compile(); |
435
|
|
|
} |
436
|
|
|
|
437
|
|
View Code Duplication |
public function testGeocoder() |
|
|
|
|
438
|
|
|
{ |
439
|
|
|
$this->loadConfiguration($this->container, 'geocoder'); |
440
|
|
|
$this->container->compile(); |
441
|
|
|
|
442
|
|
|
$geocoder = $this->container->get('ivory.google_map.geocoder'); |
443
|
|
|
|
444
|
|
|
$this->assertInstanceOf(GeocoderProvider::class, $geocoder); |
445
|
|
|
$this->assertSame($this->client, $geocoder->getClient()); |
446
|
|
|
$this->assertSame($this->messageFactory, $geocoder->getMessageFactory()); |
447
|
|
|
$this->assertTrue($geocoder->isHttps()); |
448
|
|
|
$this->assertSame(GeocoderProvider::FORMAT_JSON, $geocoder->getFormat()); |
449
|
|
|
$this->assertFalse($geocoder->hasBusinessAccount()); |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
public function testGeocoderHttps() |
453
|
|
|
{ |
454
|
|
|
$this->loadConfiguration($this->container, 'geocoder_https'); |
455
|
|
|
$this->container->compile(); |
456
|
|
|
|
457
|
|
|
$this->assertFalse($this->container->get('ivory.google_map.geocoder')->isHttps()); |
458
|
|
|
} |
459
|
|
|
|
460
|
|
View Code Duplication |
public function testGeocoderFormat() |
|
|
|
|
461
|
|
|
{ |
462
|
|
|
$this->loadConfiguration($this->container, 'geocoder_format'); |
463
|
|
|
$this->container->compile(); |
464
|
|
|
|
465
|
|
|
$this->assertSame( |
466
|
|
|
GeocoderProvider::FORMAT_XML, |
467
|
|
|
$this->container->get('ivory.google_map.geocoder')->getFormat() |
468
|
|
|
); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
View Code Duplication |
public function testGeocoderApiKey() |
|
|
|
|
472
|
|
|
{ |
473
|
|
|
$this->loadConfiguration($this->container, 'geocoder_api_key'); |
474
|
|
|
$this->container->compile(); |
475
|
|
|
|
476
|
|
|
$this->assertSame('key', $this->container->get('ivory.google_map.geocoder')->getKey()); |
477
|
|
|
} |
478
|
|
|
|
479
|
|
View Code Duplication |
public function testGeocoderBusinessAccount() |
|
|
|
|
480
|
|
|
{ |
481
|
|
|
$this->loadConfiguration($this->container, 'geocoder_business_account'); |
482
|
|
|
$this->container->compile(); |
483
|
|
|
|
484
|
|
|
$geocoder = $this->container->get('ivory.google_map.geocoder'); |
485
|
|
|
|
486
|
|
|
$this->assertTrue($geocoder->hasBusinessAccount()); |
487
|
|
|
$this->assertSame('my-client', $geocoder->getBusinessAccount()->getClientId()); |
488
|
|
|
$this->assertSame('my-secret', $geocoder->getBusinessAccount()->getSecret()); |
489
|
|
|
$this->assertFalse($geocoder->getBusinessAccount()->hasChannel()); |
490
|
|
|
} |
491
|
|
|
|
492
|
|
View Code Duplication |
public function testGeocoderBusinessAccountChannel() |
|
|
|
|
493
|
|
|
{ |
494
|
|
|
$this->loadConfiguration($this->container, 'geocoder_business_account_channel'); |
495
|
|
|
$this->container->compile(); |
496
|
|
|
|
497
|
|
|
$geocoder = $this->container->get('ivory.google_map.geocoder'); |
498
|
|
|
|
499
|
|
|
$this->assertTrue($geocoder->hasBusinessAccount()); |
500
|
|
|
$this->assertSame('my-client', $geocoder->getBusinessAccount()->getClientId()); |
501
|
|
|
$this->assertSame('my-secret', $geocoder->getBusinessAccount()->getSecret()); |
502
|
|
|
$this->assertSame('my-channel', $geocoder->getBusinessAccount()->getChannel()); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
507
|
|
|
*/ |
508
|
|
|
public function testGeocoderBusinessAccountInvalid() |
509
|
|
|
{ |
510
|
|
|
$this->loadConfiguration($this->container, 'geocoder_business_account_invalid'); |
511
|
|
|
$this->container->compile(); |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
516
|
|
|
*/ |
517
|
|
|
public function testGeocoderInvalid() |
518
|
|
|
{ |
519
|
|
|
$this->loadConfiguration($this->container, 'geocoder_invalid'); |
520
|
|
|
$this->container->compile(); |
521
|
|
|
} |
522
|
|
|
|
523
|
|
View Code Duplication |
public function testTimeZone() |
|
|
|
|
524
|
|
|
{ |
525
|
|
|
$this->loadConfiguration($this->container, 'time_zone'); |
526
|
|
|
$this->container->compile(); |
527
|
|
|
|
528
|
|
|
$timeZone = $this->container->get('ivory.google_map.time_zone'); |
529
|
|
|
|
530
|
|
|
$this->assertInstanceOf(TimeZone::class, $timeZone); |
531
|
|
|
$this->assertSame($this->client, $timeZone->getClient()); |
532
|
|
|
$this->assertSame($this->messageFactory, $timeZone->getMessageFactory()); |
533
|
|
|
$this->assertTrue($timeZone->isHttps()); |
534
|
|
|
$this->assertSame(TimeZone::FORMAT_JSON, $timeZone->getFormat()); |
535
|
|
|
$this->assertFalse($timeZone->hasBusinessAccount()); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* @expectedException \InvalidArgumentException |
540
|
|
|
* @expectedExceptionMessage The http scheme is not supported. |
541
|
|
|
*/ |
542
|
|
|
public function testTimeZoneHttps() |
543
|
|
|
{ |
544
|
|
|
$this->loadConfiguration($this->container, 'time_zone_https'); |
545
|
|
|
$this->container->compile(); |
546
|
|
|
|
547
|
|
|
$this->container->get('ivory.google_map.time_zone'); |
548
|
|
|
} |
549
|
|
|
|
550
|
|
View Code Duplication |
public function testTimeZoneFormat() |
|
|
|
|
551
|
|
|
{ |
552
|
|
|
$this->loadConfiguration($this->container, 'time_zone_format'); |
553
|
|
|
$this->container->compile(); |
554
|
|
|
|
555
|
|
|
$this->assertSame(TimeZone::FORMAT_XML, $this->container->get('ivory.google_map.time_zone')->getFormat()); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
public function testTimeZoneApiKey() |
559
|
|
|
{ |
560
|
|
|
$this->loadConfiguration($this->container, 'time_zone_api_key'); |
561
|
|
|
$this->container->compile(); |
562
|
|
|
|
563
|
|
|
$this->assertSame('key', $this->container->get('ivory.google_map.time_zone')->getKey()); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
public function testTimeZoneBusinessAccount() |
567
|
|
|
{ |
568
|
|
|
$this->loadConfiguration($this->container, 'time_zone_business_account'); |
569
|
|
|
$this->container->compile(); |
570
|
|
|
|
571
|
|
|
$timeZone = $this->container->get('ivory.google_map.time_zone'); |
572
|
|
|
|
573
|
|
|
$this->assertTrue($timeZone->hasBusinessAccount()); |
574
|
|
|
$this->assertSame('my-client', $timeZone->getBusinessAccount()->getClientId()); |
575
|
|
|
$this->assertSame('my-secret', $timeZone->getBusinessAccount()->getSecret()); |
576
|
|
|
$this->assertFalse($timeZone->getBusinessAccount()->hasChannel()); |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
public function testTimeZoneBusinessAccountChannel() |
580
|
|
|
{ |
581
|
|
|
$this->loadConfiguration($this->container, 'time_zone_business_account_channel'); |
582
|
|
|
$this->container->compile(); |
583
|
|
|
|
584
|
|
|
$timeZone = $this->container->get('ivory.google_map.time_zone'); |
585
|
|
|
|
586
|
|
|
$this->assertTrue($timeZone->hasBusinessAccount()); |
587
|
|
|
$this->assertSame('my-client', $timeZone->getBusinessAccount()->getClientId()); |
588
|
|
|
$this->assertSame('my-secret', $timeZone->getBusinessAccount()->getSecret()); |
589
|
|
|
$this->assertSame('my-channel', $timeZone->getBusinessAccount()->getChannel()); |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
/** |
593
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
594
|
|
|
*/ |
595
|
|
|
public function testTimeZoneBusinessAccountInvalid() |
596
|
|
|
{ |
597
|
|
|
$this->loadConfiguration($this->container, 'time_zone_business_account_invalid'); |
598
|
|
|
$this->container->compile(); |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
603
|
|
|
*/ |
604
|
|
|
public function testTimeZoneInvalid() |
605
|
|
|
{ |
606
|
|
|
$this->loadConfiguration($this->container, 'time_zone_invalid'); |
607
|
|
|
$this->container->compile(); |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
/** |
611
|
|
|
* @expectedException \RuntimeException |
612
|
|
|
* @expectedExceptionMessage No "class" attribute found for the tag "ivory.google_map.helper.renderer.extendable" on the service "acme.map.helper.renderer.extendable". |
613
|
|
|
*/ |
614
|
|
|
public function testMissingExtendableRendererClassTagAttribute() |
615
|
|
|
{ |
616
|
|
|
$this->loadConfiguration($this->container, 'extendable'); |
617
|
|
|
$this->container->compile(); |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
/** |
621
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject|HttpClient |
622
|
|
|
*/ |
623
|
|
|
private function createClientMock() |
624
|
|
|
{ |
625
|
|
|
return $this->createMock(HttpClient::class); |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject|MessageFactory |
630
|
|
|
*/ |
631
|
|
|
private function createMessageFactoryMock() |
632
|
|
|
{ |
633
|
|
|
return $this->createMock(MessageFactory::class); |
634
|
|
|
} |
635
|
|
|
} |
636
|
|
|
|