Completed
Pull Request — 3.x (#380)
by
unknown
19:11
created

AddTemplatesCompilerPassTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetThemes() 0 38 1
A registerCompilerPass() 0 4 1
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\DoctrineMongoDBAdminBundle\Tests\DependencyInjection\Compiler;
15
16
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
17
use Sonata\DoctrineMongoDBAdminBundle\DependencyInjection\Compiler\AddTemplatesCompilerPass;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Definition;
20
21
final class AddTemplatesCompilerPassTest extends AbstractCompilerPassTestCase
22
{
23
    public function testSetThemes(): void
24
    {
25
        $adminServiceId = 'admin_id';
26
        $adminService = new Definition();
27
        $adminService->addTag('sonata.admin', ['manager_type' => 'doctrine_mongodb']);
28
        $this->setDefinition($adminServiceId, $adminService);
29
30
        $formTemplates = [
31
            'form.html.twig',
32
        ];
33
        $filterTemplates = [
34
            'filter.html.twig',
35
        ];
36
        $templates = [
37
            'form' => $formTemplates,
38
            'filter' => $filterTemplates,
39
        ];
40
41
        $this->setParameter('sonata_doctrine_mongodb_admin.templates', $templates);
42
43
        $this->compile();
44
45
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
46
            $adminServiceId,
47
            'setFormTheme',
48
            [
49
                $formTemplates,
50
            ]
51
        );
52
53
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
54
            $adminServiceId,
55
            'setFilterTheme',
56
            [
57
                $filterTemplates,
58
            ]
59
        );
60
    }
61
62
    protected function registerCompilerPass(ContainerBuilder $container): void
63
    {
64
        $container->addCompilerPass(new AddTemplatesCompilerPass());
65
    }
66
}
67