Completed
Push — master ( e6c9d7...cc6bd7 )
by Grégoire
12:23
created

ModelManagerCompilerPassTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 2
A testProcess() 0 19 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\AdminBundle\Tests\DependencyInjection;
15
16
use PHPUnit\Framework\TestCase;
17
use Prophecy\Argument;
18
use Sonata\AdminBundle\DependencyInjection\Compiler\ModelManagerCompilerPass;
19
use Sonata\AdminBundle\Maker\AdminMaker;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\DependencyInjection\Definition;
22
23
/**
24
 * @author Gaurav Singh Faujdar <[email protected]>
25
 */
26
class ModelManagerCompilerPassTest extends TestCase
27
{
28
    /**
29
     * @var AdminMaker
30
     */
31
    private $adminMaker;
32
33
    public function setUp(): void
34
    {
35
        if (!class_exists('Symfony\Component\Console\CommandLoader\CommandLoaderInterface')) {
36
            $this->markTestSkipped('Test only available for SF 3.4');
37
        }
38
39
        parent::setUp();
40
        $this->adminMaker = $this->prophesize(Definition::class);
41
        $this->adminMaker->replaceArgument(Argument::type('integer'), Argument::any())->shouldBeCalledTimes(2);
42
    }
43
44
    public function testProcess(): void
45
    {
46
        $containerBuilderMock = $this->prophesize(ContainerBuilder::class);
47
48
        $containerBuilderMock->getDefinition(Argument::exact('sonata.admin.maker'))
49
            ->willReturn($this->adminMaker);
50
51
        $containerBuilderMock->hasDefinition(Argument::containingString('sonata.admin.manager'))
52
            ->willReturn(null);
53
        $containerBuilderMock->getDefinition(Argument::containingString('sonata.admin.manager'))
54
            ->willReturn(null);
55
        $containerBuilderMock->getParameter(Argument::containingString('kernel.project_dir'))
56
            ->willReturn(null);
57
58
        $compilerPass = new ModelManagerCompilerPass();
59
        $compilerPass->process($containerBuilderMock->reveal());
60
61
        $this->verifyMockObjects();
62
    }
63
}
64