GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 4ffd89...50b3f1 )
by Eric
02:13
created

testTimeZoneInvalid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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\Geocoder\GeocoderProvider;
23
use Ivory\GoogleMap\Service\TimeZone\TimeZone;
24
use Ivory\GoogleMapBundle\DependencyInjection\IvoryGoogleMapExtension;
25
use Ivory\GoogleMapBundle\IvoryGoogleMapBundle;
26
use Symfony\Component\DependencyInjection\ContainerBuilder;
27
use Symfony\Component\DependencyInjection\Definition;
28
29
/**
30
 * @author GeLo <[email protected]>
31
 */
32
abstract class AbstractIvoryGoogleMapExtensionTest extends \PHPUnit_Framework_TestCase
33
{
34
    /**
35
     * @var ContainerBuilder
36
     */
37
    private $container;
38
39
    /**
40
     * @var bool
41
     */
42
    private $debug;
43
44
    /**
45
     * @var string
46
     */
47
    private $locale;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
48
49
    /**
50
     * @var HttpClient|\PHPUnit_Framework_MockObject_MockObject
51
     */
52
    private $client;
53
54
    /**
55
     * @var MessageFactory|\PHPUnit_Framework_MockObject_MockObject
56
     */
57
    private $messageFactory;
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    protected function setUp()
63
    {
64
        $this->container = new ContainerBuilder();
65
        $this->container->setParameter('kernel.debug', $this->debug = false);
66
        $this->container->setParameter('locale', $this->locale = 'en');
67
        $this->container->set('httplug.client', $this->client = $this->createClientMock());
68
        $this->container->set('httplug.message_factory', $this->messageFactory = $this->createMessageFactoryMock());
69
        $this->container->registerExtension($extension = new IvoryGoogleMapExtension());
70
        $this->container->loadFromExtension($extension->getAlias());
71
        (new IvoryGoogleMapBundle())->build($this->container);
72
    }
73
74
    /**
75
     * @param ContainerBuilder $container
76
     * @param string           $configuration
77
     */
78
    abstract protected function loadConfiguration(ContainerBuilder $container, $configuration);
79
80
    public function testDefaultState()
81
    {
82
        $this->container->compile();
83
84
        $apiHelper = $this->container->get('ivory.google_map.helper.api');
85
        $mapHelper = $this->container->get('ivory.google_map.helper.map');
86
        $placeAutocompleteHelper = $this->container->get('ivory.google_map.helper.place_autocomplete');
87
88
        $this->assertInstanceOf(ApiHelper::class, $apiHelper);
89
        $this->assertInstanceOf(MapHelper::class, $mapHelper);
90
        $this->assertInstanceOf(PlaceAutocompleteHelper::class, $placeAutocompleteHelper);
91
92
        $formatter = $this->container->get('ivory.google_map.helper.formatter');
93
        $loaderRenderer = $this->container->get('ivory.google_map.helper.renderer.loader');;
94
95
        $this->assertSame($this->debug, $formatter->isDebug());
96
        $this->assertSame($this->locale, $loaderRenderer->getLanguage());
97
        $this->assertFalse($loaderRenderer->hasKey());
98
99
        $this->assertTrue($this->container->get('ivory.google_map.helper.renderer.control.manager')->hasRenderers());
100
        $this->assertTrue($this->container->get('ivory.google_map.helper.renderer.overlay.extendable')->hasRenderers());
101
        $this->assertTrue($this->container->get('ivory.google_map.helper.event_dispatcher')->hasListeners());
102
103
        $this->assertFalse($this->container->has('ivory.google_map.directions'));
104
        $this->assertFalse($this->container->has('ivory.google_map.distance_matrix'));
105
        $this->assertFalse($this->container->has('ivory.google_map.geocoder'));
106
        $this->assertFalse($this->container->has('ivory.google_map.time_zone'));
107
108
        $this->assertFalse($this->container->has('ivory.google_map.templating.api'));
109
        $this->assertFalse($this->container->has('ivory.google_map.templating.map'));
110
        $this->assertFalse($this->container->has('ivory.google_map.templating.place_autocomplete'));
111
112
        $this->assertFalse($this->container->has('ivory.google_map.twig.extension.api'));
113
        $this->assertFalse($this->container->has('ivory.google_map.twig.extension.map'));
114
        $this->assertFalse($this->container->has('ivory.google_map.twig.extension.place_autocomplete'));
115
    }
116
117 View Code Duplication
    public function testTemplatingHelpers()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
    {
119
        $this->container->setDefinition('templating.engine.php', new Definition(\stdClass::class));
120
        $this->container->compile();
121
122
        $this->assertTrue($this->container->has('ivory.google_map.templating.api'));
123
        $this->assertTrue($this->container->has('ivory.google_map.templating.map'));
124
        $this->assertTrue($this->container->has('ivory.google_map.templating.place_autocomplete'));
125
    }
126
127 View Code Duplication
    public function testTwigExtensions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
128
    {
129
        $this->container->setDefinition('twig', new Definition(\stdClass::class));
130
        $this->container->compile();
131
132
        $this->assertTrue($this->container->has('ivory.google_map.twig.extension.api'));
133
        $this->assertTrue($this->container->has('ivory.google_map.twig.extension.map'));
134
        $this->assertTrue($this->container->has('ivory.google_map.twig.extension.place_autocomplete'));
135
    }
136
137 View Code Duplication
    public function testTemplatingFormResources()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
    {
139
        $this->container->setParameter($parameter = 'templating.helper.form.resources', $resources = ['resource']);
140
        $this->container->compile();
141
142
        $this->assertSame(
143
            array_merge(['IvoryGoogleMapBundle:Form'], $resources),
144
            $this->container->getParameter($parameter)
145
        );
146
    }
147
148 View Code Duplication
    public function testTwigFormResources()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
149
    {
150
        $this->container->setParameter($parameter = 'twig.form.resources', $resources = ['resource']);
151
        $this->container->compile();
152
153
        $this->assertSame(
154
            array_merge(['IvoryGoogleMapBundle:Form:place_autocomplete_widget.html.twig'], $resources),
155
            $this->container->getParameter($parameter)
156
        );
157
    }
158
159
    public function testFormatterDebug()
160
    {
161
        $this->loadConfiguration($this->container, 'debug');
162
        $this->container->compile();
163
164
        $this->assertTrue($this->container->get('ivory.google_map.helper.formatter')->isDebug());
165
    }
166
167 View Code Duplication
    public function testMapLanguage()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
168
    {
169
        $this->loadConfiguration($this->container, 'language');
170
        $this->container->compile();
171
172
        $this->assertSame('fr', $this->container->get('ivory.google_map.helper.renderer.loader')->getLanguage());
173
    }
174
175 View Code Duplication
    public function testMapApiKey()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
176
    {
177
        $this->loadConfiguration($this->container, 'api_key');
178
        $this->container->compile();
179
180
        $this->assertSame('key', $this->container->get('ivory.google_map.helper.renderer.loader')->getKey());
181
    }
182
183 View Code Duplication
    public function testDirections()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
184
    {
185
        $this->loadConfiguration($this->container, 'directions');
186
        $this->container->compile();
187
188
        $directions = $this->container->get('ivory.google_map.directions');
189
190
        $this->assertInstanceOf(Directions::class, $directions);
191
        $this->assertSame($this->client, $directions->getClient());
192
        $this->assertSame($this->messageFactory, $directions->getMessageFactory());
193
        $this->assertTrue($directions->isHttps());
194
        $this->assertSame(Directions::FORMAT_JSON, $directions->getFormat());
195
        $this->assertFalse($directions->hasBusinessAccount());
196
    }
197
198
    public function testDirectionsHttps()
199
    {
200
        $this->loadConfiguration($this->container, 'directions_https');
201
        $this->container->compile();
202
203
        $this->assertFalse($this->container->get('ivory.google_map.directions')->isHttps());
204
    }
205
206 View Code Duplication
    public function testDirectionsFormat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
207
    {
208
        $this->loadConfiguration($this->container, 'directions_format');
209
        $this->container->compile();
210
211
        $this->assertSame(Directions::FORMAT_XML, $this->container->get('ivory.google_map.directions')->getFormat());
212
    }
213
214 View Code Duplication
    public function testDirectionsApiKey()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
215
    {
216
        $this->loadConfiguration($this->container, 'directions_api_key');
217
        $this->container->compile();
218
219
        $this->assertSame('key', $this->container->get('ivory.google_map.directions')->getKey());
220
    }
221
222 View Code Duplication
    public function testDirectionsBusinessAccount()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
223
    {
224
        $this->loadConfiguration($this->container, 'directions_business_account');
225
        $this->container->compile();
226
227
        $directions = $this->container->get('ivory.google_map.directions');
228
229
        $this->assertTrue($directions->hasBusinessAccount());
230
        $this->assertSame('my-client', $directions->getBusinessAccount()->getClientId());
231
        $this->assertSame('my-secret', $directions->getBusinessAccount()->getSecret());
232
        $this->assertFalse($directions->getBusinessAccount()->hasChannel());
233
    }
234
235 View Code Duplication
    public function testDirectionsBusinessAccountChannel()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
236
    {
237
        $this->loadConfiguration($this->container, 'directions_business_account_channel');
238
        $this->container->compile();
239
240
        $directions = $this->container->get('ivory.google_map.directions');
241
242
        $this->assertTrue($directions->hasBusinessAccount());
243
        $this->assertSame('my-client', $directions->getBusinessAccount()->getClientId());
244
        $this->assertSame('my-secret', $directions->getBusinessAccount()->getSecret());
245
        $this->assertSame('my-channel', $directions->getBusinessAccount()->getChannel());
246
    }
247
248
    /**
249
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
250
     */
251
    public function testDirectionsBusinessAccountInvalid()
252
    {
253
        $this->loadConfiguration($this->container, 'directions_business_account_invalid');
254
        $this->container->compile();
255
    }
256
257
    /**
258
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
259
     */
260
    public function testDirectionsInvalid()
261
    {
262
        $this->loadConfiguration($this->container, 'directions_invalid');
263
        $this->container->compile();
264
    }
265
266 View Code Duplication
    public function testDistanceMatrix()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
267
    {
268
        $this->loadConfiguration($this->container, 'distance_matrix');
269
        $this->container->compile();
270
271
        $distanceMatrix = $this->container->get('ivory.google_map.distance_matrix');
272
273
        $this->assertInstanceOf(DistanceMatrix::class, $distanceMatrix);
274
        $this->assertSame($this->client, $distanceMatrix->getClient());
275
        $this->assertSame($this->messageFactory, $distanceMatrix->getMessageFactory());
276
        $this->assertTrue($distanceMatrix->isHttps());
277
        $this->assertSame(DistanceMatrix::FORMAT_JSON, $distanceMatrix->getFormat());
278
        $this->assertFalse($distanceMatrix->hasBusinessAccount());
279
    }
280
281
    public function testDistanceMatrixHttps()
282
    {
283
        $this->loadConfiguration($this->container, 'distance_matrix_https');
284
        $this->container->compile();
285
286
        $this->assertFalse($this->container->get('ivory.google_map.distance_matrix')->isHttps());
287
    }
288
289 View Code Duplication
    public function testDistanceMatrixFormat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
290
    {
291
        $this->loadConfiguration($this->container, 'distance_matrix_format');
292
        $this->container->compile();
293
294
        $this->assertSame(
295
            DistanceMatrix::FORMAT_XML,
296
            $this->container->get('ivory.google_map.distance_matrix')->getFormat()
297
        );
298
    }
299
300 View Code Duplication
    public function testDistanceMatrixApiKey()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
301
    {
302
        $this->loadConfiguration($this->container, 'distance_matrix_api_key');
303
        $this->container->compile();
304
305
        $this->assertSame('key', $this->container->get('ivory.google_map.distance_matrix')->getKey());
306
    }
307
308 View Code Duplication
    public function testDistanceMatrixBusinessAccount()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
309
    {
310
        $this->loadConfiguration($this->container, 'distance_matrix_business_account');
311
        $this->container->compile();
312
313
        $distanceMatrix = $this->container->get('ivory.google_map.distance_matrix');
314
315
        $this->assertTrue($distanceMatrix->hasBusinessAccount());
316
        $this->assertSame('my-client', $distanceMatrix->getBusinessAccount()->getClientId());
317
        $this->assertSame('my-secret', $distanceMatrix->getBusinessAccount()->getSecret());
318
        $this->assertFalse($distanceMatrix->getBusinessAccount()->hasChannel());
319
    }
320
321 View Code Duplication
    public function testDistanceMatrixBusinessAccountChannel()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
322
    {
323
        $this->loadConfiguration($this->container, 'distance_matrix_business_account_channel');
324
        $this->container->compile();
325
326
        $distanceMatrix = $this->container->get('ivory.google_map.distance_matrix');
327
328
        $this->assertTrue($distanceMatrix->hasBusinessAccount());
329
        $this->assertSame('my-client', $distanceMatrix->getBusinessAccount()->getClientId());
330
        $this->assertSame('my-secret', $distanceMatrix->getBusinessAccount()->getSecret());
331
        $this->assertSame('my-channel', $distanceMatrix->getBusinessAccount()->getChannel());
332
    }
333
334
    /**
335
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
336
     */
337
    public function testDistanceMatrixBusinessAccountInvalid()
338
    {
339
        $this->loadConfiguration($this->container, 'distance_matrix_business_account_invalid');
340
        $this->container->compile();
341
    }
342
343
    /**
344
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
345
     */
346
    public function testDistanceMatrixInvalid()
347
    {
348
        $this->loadConfiguration($this->container, 'distance_matrix_invalid');
349
        $this->container->compile();
350
    }
351
352 View Code Duplication
    public function testGeocoder()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
353
    {
354
        $this->loadConfiguration($this->container, 'geocoder');
355
        $this->container->compile();
356
357
        $geocoder = $this->container->get('ivory.google_map.geocoder');
358
359
        $this->assertInstanceOf(GeocoderProvider::class, $geocoder);
360
        $this->assertSame($this->client, $geocoder->getClient());
361
        $this->assertSame($this->messageFactory, $geocoder->getMessageFactory());
362
        $this->assertTrue($geocoder->isHttps());
363
        $this->assertSame(GeocoderProvider::FORMAT_JSON, $geocoder->getFormat());
364
        $this->assertFalse($geocoder->hasBusinessAccount());
365
    }
366
367
    public function testGeocoderHttps()
368
    {
369
        $this->loadConfiguration($this->container, 'geocoder_https');
370
        $this->container->compile();
371
372
        $this->assertFalse($this->container->get('ivory.google_map.geocoder')->isHttps());
373
    }
374
375 View Code Duplication
    public function testGeocoderFormat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
376
    {
377
        $this->loadConfiguration($this->container, 'geocoder_format');
378
        $this->container->compile();
379
380
        $this->assertSame(
381
            GeocoderProvider::FORMAT_XML,
382
            $this->container->get('ivory.google_map.geocoder')->getFormat()
383
        );
384
    }
385
386 View Code Duplication
    public function testGeocoderApiKey()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
387
    {
388
        $this->loadConfiguration($this->container, 'geocoder_api_key');
389
        $this->container->compile();
390
391
        $this->assertSame('key', $this->container->get('ivory.google_map.geocoder')->getKey());
392
    }
393
394 View Code Duplication
    public function testGeocoderBusinessAccount()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
395
    {
396
        $this->loadConfiguration($this->container, 'geocoder_business_account');
397
        $this->container->compile();
398
399
        $geocoder = $this->container->get('ivory.google_map.geocoder');
400
401
        $this->assertTrue($geocoder->hasBusinessAccount());
402
        $this->assertSame('my-client', $geocoder->getBusinessAccount()->getClientId());
403
        $this->assertSame('my-secret', $geocoder->getBusinessAccount()->getSecret());
404
        $this->assertFalse($geocoder->getBusinessAccount()->hasChannel());
405
    }
406
407 View Code Duplication
    public function testGeocoderBusinessAccountChannel()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
408
    {
409
        $this->loadConfiguration($this->container, 'geocoder_business_account_channel');
410
        $this->container->compile();
411
412
        $geocoder = $this->container->get('ivory.google_map.geocoder');
413
414
        $this->assertTrue($geocoder->hasBusinessAccount());
415
        $this->assertSame('my-client', $geocoder->getBusinessAccount()->getClientId());
416
        $this->assertSame('my-secret', $geocoder->getBusinessAccount()->getSecret());
417
        $this->assertSame('my-channel', $geocoder->getBusinessAccount()->getChannel());
418
    }
419
420
    /**
421
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
422
     */
423
    public function testGeocoderBusinessAccountInvalid()
424
    {
425
        $this->loadConfiguration($this->container, 'geocoder_business_account_invalid');
426
        $this->container->compile();
427
    }
428
429
    /**
430
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
431
     */
432
    public function testGeocoderInvalid()
433
    {
434
        $this->loadConfiguration($this->container, 'geocoder_invalid');
435
        $this->container->compile();
436
    }
437
438 View Code Duplication
    public function testTimeZone()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
439
    {
440
        $this->loadConfiguration($this->container, 'time_zone');
441
        $this->container->compile();
442
443
        $timeZone = $this->container->get('ivory.google_map.time_zone');
444
445
        $this->assertInstanceOf(TimeZone::class, $timeZone);
446
        $this->assertSame($this->client, $timeZone->getClient());
447
        $this->assertSame($this->messageFactory, $timeZone->getMessageFactory());
448
        $this->assertTrue($timeZone->isHttps());
449
        $this->assertSame(TimeZone::FORMAT_JSON, $timeZone->getFormat());
450
        $this->assertFalse($timeZone->hasBusinessAccount());
451
    }
452
453
    /**
454
     * @expectedException \InvalidArgumentException
455
     * @expectedExceptionMessage The http scheme is not supported.
456
     */
457
    public function testTimeZoneHttps()
458
    {
459
        $this->loadConfiguration($this->container, 'time_zone_https');
460
        $this->container->compile();
461
462
        $this->container->get('ivory.google_map.time_zone');
463
    }
464
465 View Code Duplication
    public function testTimeZoneFormat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
466
    {
467
        $this->loadConfiguration($this->container, 'time_zone_format');
468
        $this->container->compile();
469
470
        $this->assertSame(TimeZone::FORMAT_XML, $this->container->get('ivory.google_map.time_zone')->getFormat());
471
    }
472
473 View Code Duplication
    public function testTimeZoneApiKey()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
474
    {
475
        $this->loadConfiguration($this->container, 'time_zone_api_key');
476
        $this->container->compile();
477
478
        $this->assertSame('key', $this->container->get('ivory.google_map.time_zone')->getKey());
479
    }
480
481 View Code Duplication
    public function testTimeZoneBusinessAccount()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
482
    {
483
        $this->loadConfiguration($this->container, 'time_zone_business_account');
484
        $this->container->compile();
485
486
        $timeZone = $this->container->get('ivory.google_map.time_zone');
487
488
        $this->assertTrue($timeZone->hasBusinessAccount());
489
        $this->assertSame('my-client', $timeZone->getBusinessAccount()->getClientId());
490
        $this->assertSame('my-secret', $timeZone->getBusinessAccount()->getSecret());
491
        $this->assertFalse($timeZone->getBusinessAccount()->hasChannel());
492
    }
493
494 View Code Duplication
    public function testTimeZoneBusinessAccountChannel()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
495
    {
496
        $this->loadConfiguration($this->container, 'time_zone_business_account_channel');
497
        $this->container->compile();
498
499
        $timeZone = $this->container->get('ivory.google_map.time_zone');
500
501
        $this->assertTrue($timeZone->hasBusinessAccount());
502
        $this->assertSame('my-client', $timeZone->getBusinessAccount()->getClientId());
503
        $this->assertSame('my-secret', $timeZone->getBusinessAccount()->getSecret());
504
        $this->assertSame('my-channel', $timeZone->getBusinessAccount()->getChannel());
505
    }
506
507
    /**
508
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
509
     */
510
    public function testTimeZoneBusinessAccountInvalid()
511
    {
512
        $this->loadConfiguration($this->container, 'time_zone_business_account_invalid');
513
        $this->container->compile();
514
    }
515
516
    /**
517
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
518
     */
519
    public function testTimeZoneInvalid()
520
    {
521
        $this->loadConfiguration($this->container, 'time_zone_invalid');
522
        $this->container->compile();
523
    }
524
525
    /**
526
     * @expectedException \RuntimeException
527
     * @expectedExceptionMessage No "class" attribute found for the tag "ivory.google_map.helper.renderer.extendable" on the service "acme.map.helper.renderer.extendable".
528
     */
529
    public function testMissingExtendableRendererClassTagAttribute()
530
    {
531
        $this->loadConfiguration($this->container, 'extendable');
532
        $this->container->compile();
533
    }
534
535
    /**
536
     * @return \PHPUnit_Framework_MockObject_MockObject|HttpClient
537
     */
538
    private function createClientMock()
539
    {
540
        return $this->createMock(HttpClient::class);
541
    }
542
543
    /**
544
     * @return \PHPUnit_Framework_MockObject_MockObject|MessageFactory
545
     */
546
    private function createMessageFactoryMock()
547
    {
548
        return $this->createMock(MessageFactory::class);
549
    }
550
}
551