Completed
Push — master ( 9b72b2...6d9bc6 )
by Christian
02:23
created

ExecuteCodeTest::getConfigMock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace uuf6429\ElderBrother\Action;
4
5
use Symfony\Component\Console\Input;
6
use Symfony\Component\Console\Output;
7
use uuf6429\ElderBrother\Config\ConfigInterface;
8
9
class ExecuteCodeTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testThatExceptionIsPropagated()
12
    {
13
        $action = new ExecuteCode(
14
            'Do something',
15
            function ($config, $input, $output) {
16
                $this->assertInstanceOf(ConfigInterface::class, $config);
17
                $this->assertInstanceOf(Input\InputInterface::class, $input);
18
                $this->assertInstanceOf(Output\OutputInterface::class, $output);
19
20
                throw new \RuntimeException('Testing');
21
            }
22
        );
23
24
        $action->setConfig($this->getConfigMock());
0 ignored issues
show
Bug introduced by
It seems like $this->getConfigMock() targeting uuf6429\ElderBrother\Act...deTest::getConfigMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, uuf6429\ElderBrother\Act...onAbstract::setConfig() does only seem to accept object<uuf6429\ElderBrot...Config\ConfigInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
25
26
        $this->setExpectedException(\RuntimeException::class, 'Testing');
27
28
        $action->execute(new Input\StringInput(''), new Output\NullOutput());
29
30
        $this->assertSame('Do something (ExecuteCode)', $action->getName());
31
    }
32
33
    /**
34
     * @return ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
35
     */
36
    protected function getConfigMock()
37
    {
38
        return $this->getMockBuilder(ConfigInterface::class)
39
            ->disableOriginalConstructor()
40
            ->getMock();
41
    }
42
}
43