Completed
Pull Request — master (#471)
by Timothy
15:13
created

CheckCommandTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace DoctrineORMModuleTest\Diagnostics;
4
5
use DoctrineModule\Component\Console\Output\PropertyOutput;
6
use DoctrineORMModule\Diagnostics\CheckCommand;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use ZendDiagnostics\Result\Failure;
11
use ZendDiagnostics\Result\Success;
12
13
class CheckCommandTest extends \PHPUnit_Framework_TestCase
14
{
15
    /** @var \PHPUnit_Framework_MockObject_MockObject|Command */
16
    private $command;
17
    
18
    /** @var \PHPUnit_Framework_MockObject_MockObject|InputInterface */
19
    private $input;
20
    
21
    /** @var \PHPUnit_Framework_MockObject_MockObject|OutputInterface */
22
    private $output;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
23
    
24
    /** @var CheckCommand */
25
    private $sut;
26
27
    protected function setUp()
28
    {
29
        parent::setUp();
30
31
        $this->command = $this->getMockBuilder(Command::class)
32
            ->disableOriginalConstructor()
33
            ->getMock();
34
        
35
        $this->input = $this->getMock(InputInterface::class);
36
37
        $this->output = $this->getMock(OutputInterface::class);
38
        
39
        $this->sut = new CheckCommand($this->command, $this->input, $this->output);
40
    }
41
    
42
    public function testCheckCommandSuccessful()
43
    {
44
        $this->command->method('run')->willReturn(0);
45
        
46
        $actual = $this->sut->check();
47
        
48
        self::assertInstanceOf(Success::class, $actual);
49
    }
50
    
51
    public function testCheckCommandFailed()
52
    {
53
        $this->command->method('run')->willReturn(1);
54
        
55
        $actual = $this->sut->check();
56
        
57
        self::assertInstanceOf(Failure::class, $actual);
58
    }
59
    
60
    public function testCheckWithPropertyOutput()
61
    {
62
        /** @var \PHPUnit_Framework_MockObject_MockObject|PropertyOutput $output */
63
        $output = $this->getMock(PropertyOutput::class);
64
        
65
        $output->method('getMessage')
66
            ->willReturn("Foo\nBar\n");
67
        
68
        $this->command->method('run')->willReturn(1);
69
        
70
        $actual = (new CheckCommand($this->command, $this->input, $output))->check();
71
        
72
        self::assertInternalType('array', $actual->getData());
73
        self::assertContains('Foo', $actual->getData());
74
        self::assertContains('Bar', $actual->getData());
75
    }
76
}
77