Completed
Push — 3.x ( 9aa22d...aa303f )
by Grégoire
04:40
created

AdminMakerCompilerPassTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
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 3
A testProcess() 0 19 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\AdminBundle\Tests\DependencyInjection;
13
14
use PHPUnit\Framework\TestCase;
15
use Prophecy\Argument;
16
use Sonata\AdminBundle\DependencyInjection\Compiler\AdminMakerCompilerPass;
17
use Sonata\AdminBundle\Maker\AdminMaker;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Definition;
20
21
/**
22
 * @author Gaurav Singh Faujdar <[email protected]>
23
 */
24
class AdminMakerCompilerPassTest extends TestCase
25
{
26
    /**
27
     * @var AdminMaker
28
     */
29
    private $adminMaker;
30
31
    public function setUp()
32
    {
33
        if (5 == PHP_MAJOR_VERSION || !class_exists('Symfony\Component\Console\CommandLoader\CommandLoaderInterface')) {
34
            $this->markTestSkipped('Test only available for PHP 7 and SF 3.4');
35
        }
36
37
        parent::setUp();
38
        $this->adminMaker = $this->prophesize(Definition::class);
39
        $this->adminMaker->replaceArgument(Argument::type('integer'), Argument::any())->shouldBeCalledTimes(2);
40
    }
41
42
    public function testProcess()
43
    {
44
        $containerBuilderMock = $this->prophesize(ContainerBuilder::class);
45
46
        $containerBuilderMock->getDefinition(Argument::exact('sonata.admin.maker'))
47
            ->willReturn($this->adminMaker);
48
49
        $containerBuilderMock->hasDefinition(Argument::containingString('sonata.admin.manager'))
50
            ->willReturn(null);
51
        $containerBuilderMock->getDefinition(Argument::containingString('sonata.admin.manager'))
52
            ->willReturn(null);
53
        $containerBuilderMock->getParameter(Argument::containingString('kernel.project_dir'))
54
            ->willReturn(null);
55
56
        $compilerPass = new AdminMakerCompilerPass();
57
        $compilerPass->process($containerBuilderMock->reveal());
58
59
        $this->verifyMockObjects();
60
    }
61
}
62