Completed
Push — master ( f7b33a...213343 )
by Andy
03:36
created

testAddConfigArgumentToServiceDefinitions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 1
1
<?php
2
3
namespace Palmtree\CanonicalUrlBundle\Tests\DependencyInjection\Compiler;
4
5
use Palmtree\CanonicalUrlBundle\DependencyInjection\Compiler\CompilerPass;
6
use Palmtree\CanonicalUrlBundle\EventListener\KernelEventListener;
7
use Palmtree\CanonicalUrlBundle\Service\CanonicalUrlGenerator;
8
use Palmtree\CanonicalUrlBundle\Tests\AbstractTest;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Definition;
11
12
class CompilerPassTest extends AbstractTest
13
{
14
    /**
15
     * @dataProvider configProvider
16
     */
17
    public function testAddConfigArgumentToServiceDefinitions(array $config)
18
    {
19
        $container = new ContainerBuilder();
20
        $container->setParameter('kernel.environment', 'test');
21
22
        $container->setParameter('palmtree.canonical_url.config', $config);
23
24
        $definitions = [
25
            'palmtree_canonical_url.url_generator'         => new Definition(CanonicalUrlGenerator::class),
26
            'palmtree_canonical_url.kernel_event_listener' => new Definition(KernelEventListener::class),
27
        ];
28
29
        $container->addDefinitions($definitions);
30
31
        $compilerPass = new CompilerPass();
32
33
        $compilerPass->process($container);
34
35
        foreach ($definitions as $id => $definition) {
36
            $this->assertEquals($config, $container->getDefinition($id)->getArgument(0));
37
        }
38
    }
39
40 View Code Duplication
    public function configProvider()
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...
41
    {
42
        return array(
43
            'config' => array(
44
                array(
45
                    'site_url'       => 'https://example.org',
46
                    'redirect'       => true,
47
                    'redirect_code'  => 302,
48
                    'trailing_slash' => false,
49
                )
50
            )
51
        );
52
    }
53
}
54