setContainerShouldConfigureContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 13
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of LuisMulinari\Consoleful
4
 *
5
 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
6
 */
7
8
namespace LuisMulinari\Consoleful\Command;
9
10
use Symfony\Component\DependencyInjection\ContainerInterface;
11
12
/**
13
 * Class ContainerAwareCommandTest
14
 *
15
 * @author Luis Henrique Mulinari <[email protected]>
16
 */
17
class ContainerAwareCommandTest extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @test
21
     * @expectedException \LogicException
22
     * @expectedExceptionMessage The container cannot be retrieved
23
     */
24
    public function getContainerMustRaiseExceptionWhenContainerNotConfigured()
25
    {
26
        $command = $this->getMockForAbstractClass(ContainerAwareCommand::class, ['commandName']);
27
28
        $getContainerReflectionMethod = new \ReflectionMethod($command, 'getContainer');
29
        $getContainerReflectionMethod->setAccessible(true);
30
        $getContainerReflectionMethod->invoke($command);
31
    }
32
33
    /**
34
     * @test
35
     */
36
    public function setContainerShouldConfigureContainer()
37
    {
38
        $command = $this->getMockForAbstractClass(ContainerAwareCommand::class, ['commandName']);
39
40
        $container = $this->getMock(ContainerInterface::class);
41
42
        $command->setContainer($container);
43
44
        $getContainerReflectionMethod = new \ReflectionMethod($command, 'getContainer');
45
        $getContainerReflectionMethod->setAccessible(true);
46
47
        $this->assertSame($container, $getContainerReflectionMethod->invoke($command));
48
    }
49
}
50