GenerateDTOCommandTest::testExecute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[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 Micro\Plugin\DTO\Test\Unit\Console;
15
16
use Micro\Plugin\DTO\Console\GenerateDTOCommand;
17
use Micro\Plugin\DTO\Facade\DTOFacadeInterface;
18
use PHPUnit\Framework\TestCase;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
class GenerateDTOCommandTest extends TestCase
23
{
24
    public function testExecute(): void
25
    {
26
        $facade = $this->createMock(DTOFacadeInterface::class);
27
        $facade->expects($this->once())->method('generate');
28
29
        $command = new GenerateDTOCommand(
30
            $facade
31
        );
32
        $input = $this->createMock(InputInterface::class);
33
        $output = $this->createMock(OutputInterface::class);
34
35
        $command->run($input, $output);
36
    }
37
38
    public function testExecuteException(): void
39
    {
40
        $errMsg = 'Hello, World';
41
        $facade = $this->createMock(DTOFacadeInterface::class);
42
        $facade->expects($this->once())->method('generate')->willThrowException(new \RuntimeException($errMsg));
43
44
        $command = new GenerateDTOCommand(
45
            $facade
46
        );
47
48
        $input = $this->createMock(InputInterface::class);
49
        $output = $this->createMock(OutputInterface::class);
50
51
        $this->expectException(\RuntimeException::class);
52
        $this->expectExceptionMessage($errMsg);
53
54
        $command->run($input, $output);
55
    }
56
}
57