forked from geocoder-php/BazingaGeocoderBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddProvidersPassTest.php
More file actions
50 lines (39 loc) · 1.7 KB
/
AddProvidersPassTest.php
File metadata and controls
50 lines (39 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
/*
* This file is part of the BazingaGeocoderBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Bazinga\GeocoderBundle\Tests\DependencyInjection\Compiler;
use Bazinga\GeocoderBundle\DependencyInjection\Compiler\AddProvidersPass;
use Geocoder\Provider\BingMaps\BingMaps;
use Geocoder\ProviderAggregator;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Psr18Client;
final class AddProvidersPassTest extends TestCase
{
private AddProvidersPass $compilerPass;
protected function setUp(): void
{
$this->compilerPass = new AddProvidersPass();
}
public function testRegistersProviders(): void
{
$containerBuilder = new ContainerBuilder();
$containerBuilder->setDefinition(ProviderAggregator::class, new Definition(ProviderAggregator::class));
$bing = $containerBuilder->setDefinition('bing_maps', new Definition(BingMaps::class, [new Psr18Client(new MockHttpClient()), 'apikey']));
$bing->addTag('bazinga_geocoder.provider');
$this->compilerPass->process($containerBuilder);
/** @var ProviderAggregator $providerAggregator */
$providerAggregator = $containerBuilder->get(ProviderAggregator::class);
$providers = $providerAggregator->getProviders();
self::assertArrayHasKey('bing_maps', $providers);
self::assertInstanceOf(BingMaps::class, $providers['bing_maps']);
}
}