1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\SeoBundle\Tests\DependencyInjection\Compiler; |
15
|
|
|
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
17
|
|
|
use Sonata\SeoBundle\DependencyInjection\Compiler\ServiceCompilerPass; |
18
|
|
|
use Sonata\SeoBundle\DependencyInjection\SonataSeoExtension; |
19
|
|
|
use Sonata\SeoBundle\Seo\SeoPageInterface; |
20
|
|
|
use Sonata\SeoBundle\Tests\Stubs\SeoPageStub; |
21
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
22
|
|
|
|
23
|
|
|
class ServiceCompilerPassTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
public function testServicesExistsAndCanBeOverridden() |
26
|
|
|
{ |
27
|
|
|
$container = new ContainerBuilder(); |
28
|
|
|
$container->setParameter('kernel.bundles', []); |
29
|
|
|
|
30
|
|
|
$container->register('sonata.seo.custom.page', SeoPageStub::class); |
31
|
|
|
|
32
|
|
|
$config = [ |
33
|
|
|
'page' => [ |
34
|
|
|
'default' => 'sonata.seo.custom.page', |
35
|
|
|
], |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
$extension = new SonataSeoExtension(); |
39
|
|
|
$extension->load([$config], $container); |
40
|
|
|
|
41
|
|
|
(new ServiceCompilerPass())->process($container); |
42
|
|
|
|
43
|
|
|
$this->assertTrue($service = $container->has('sonata.seo.page')); |
44
|
|
|
$this->assertTrue($alias = $container->has(SeoPageInterface::class)); |
45
|
|
|
$this->assertSame($service, $alias); |
46
|
|
|
|
47
|
|
|
$this->assertInstanceOf(SeoPageStub::class, $container->get(SeoPageInterface::class)); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|