These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Abacaphiliac\DoctrineORMDiagnosticsModuleTest; |
||
4 | |||
5 | use Abacaphiliac\DoctrineORMDiagnosticsModule\CheckCommand; |
||
6 | use DoctrineModule\Component\Console\Output\PropertyOutput; |
||
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 | /** |
||
14 | * @covers \Abacaphiliac\DoctrineORMDiagnosticsModule\CheckCommand |
||
15 | */ |
||
16 | class CheckCommandTest extends \PHPUnit_Framework_TestCase |
||
17 | { |
||
18 | /** @var \PHPUnit_Framework_MockObject_MockObject|Command */ |
||
19 | private $command; |
||
20 | |||
21 | /** @var \PHPUnit_Framework_MockObject_MockObject|InputInterface */ |
||
22 | private $input; |
||
23 | |||
24 | /** @var \PHPUnit_Framework_MockObject_MockObject|OutputInterface */ |
||
25 | private $output; |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
26 | |||
27 | /** @var CheckCommand */ |
||
28 | private $sut; |
||
29 | |||
30 | protected function setUp() |
||
31 | { |
||
32 | parent::setUp(); |
||
33 | |||
34 | $this->command = $this->getMockBuilder(Command::class) |
||
35 | ->disableOriginalConstructor() |
||
36 | ->getMock(); |
||
37 | |||
38 | $this->input = $this->getMockBuilder(InputInterface::class)->getMock(); |
||
39 | |||
40 | $this->output = $this->getMockBuilder(OutputInterface::class)->getMock(); |
||
41 | |||
42 | $this->sut = new CheckCommand($this->command, $this->input, $this->output); |
||
43 | } |
||
44 | |||
45 | View Code Duplication | public function testCheckCommandSuccessful() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
46 | { |
||
47 | $this->command->method('run')->willReturn(0); |
||
48 | |||
49 | $actual = $this->sut->check(); |
||
50 | |||
51 | self::assertInstanceOf(Success::class, $actual); |
||
52 | } |
||
53 | |||
54 | View Code Duplication | public function testCheckCommandFailed() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
55 | { |
||
56 | $this->command->method('run')->willReturn(1); |
||
57 | |||
58 | $actual = $this->sut->check(); |
||
59 | |||
60 | self::assertInstanceOf(Failure::class, $actual); |
||
61 | } |
||
62 | |||
63 | public function testCheckWithPropertyOutput() |
||
64 | { |
||
65 | /** @var \PHPUnit_Framework_MockObject_MockObject|PropertyOutput $output */ |
||
66 | $output = $this->getMockBuilder(PropertyOutput::class)->getMock(); |
||
67 | |||
68 | $output->method('getMessage') |
||
69 | ->willReturn("Foo\nBar\n"); |
||
70 | |||
71 | $this->command->method('run')->willReturn(1); |
||
72 | |||
73 | $actual = (new CheckCommand($this->command, $this->input, $output))->check(); |
||
74 | |||
75 | self::assertInternalType('array', $actual->getData()); |
||
76 | self::assertContains('Foo', $actual->getData()); |
||
77 | self::assertContains('Bar', $actual->getData()); |
||
78 | } |
||
79 | } |
||
80 |