Completed
Push — 3.x ( f37b5a...b37d45 )
by Christian
26:43
created

ModelManagerCompilerPassTest::testProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Compiler;
15
16
use PHPUnit\Framework\TestCase;
17
use Prophecy\Argument;
18
use Sonata\AdminBundle\Command\GenerateAdminCommand;
19
use Sonata\AdminBundle\DependencyInjection\Compiler\ModelManagerCompilerPass;
20
use Sonata\AdminBundle\Maker\AdminMaker;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Definition;
23
24
/**
25
 * @author Gaurav Singh Faujdar <[email protected]>
26
 */
27
class ModelManagerCompilerPassTest extends TestCase
28
{
29
    /**
30
     * @var AdminMaker
31
     */
32
    private $adminMaker;
33
    private $generateAdminCommand;
34
35
    public function setUp(): void
36
    {
37
        parent::setUp();
38
        $this->adminMaker = $this->prophesize(Definition::class);
39
        $this->adminMaker->replaceArgument(Argument::type('integer'), Argument::any())->shouldBeCalledTimes(1);
40
41
        $this->generateAdminCommand = $this->prophesize(Definition::class);
42
        $this->generateAdminCommand->replaceArgument(Argument::type('integer'), Argument::any())->shouldBeCalledTimes(1);
43
    }
44
45
    public function testProcess(): void
46
    {
47
        $containerBuilderMock = $this->prophesize(ContainerBuilder::class);
48
49
        $containerBuilderMock->getServiceIds()
50
            ->willReturn([]);
51
52
        $containerBuilderMock->getParameter(Argument::exact('kernel.bundles'))
53
            ->willReturn(['MakerBundle' => 'MakerBundle']);
54
55
        $containerBuilderMock->getDefinition(Argument::exact('sonata.admin.maker'))
56
            ->willReturn($this->adminMaker->reveal());
0 ignored issues
show
Bug introduced by
The method reveal() does not seem to exist on object<Sonata\AdminBundle\Maker\AdminMaker>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58
        $containerBuilderMock->hasDefinition(Argument::containingString('sonata.admin.manager'))
59
            ->willReturn(null);
60
        $containerBuilderMock->getDefinition(Argument::containingString('sonata.admin.manager'))
61
            ->willReturn(null);
62
        $containerBuilderMock->getParameter(Argument::containingString('kernel.project_dir'))
63
            ->willReturn(null);
64
65
        $containerBuilderMock->getDefinition(Argument::exact(GenerateAdminCommand::class))
66
            ->willReturn($this->generateAdminCommand->reveal());
67
68
        $compilerPass = new ModelManagerCompilerPass();
69
        $compilerPass->process($containerBuilderMock->reveal());
70
    }
71
}
72