Completed
Push — master ( 7fbbb0...53f538 )
by Oleg
03:37
created

AddActionCommandTest::setUpBeforeClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 24
rs 9.568
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Command;
5
6
use PHPUnit\Framework\TestCase;
7
use SlayerBirden\DFCodeGeneration\Command\Controllers\AddActionCommand;
8
use SlayerBirden\DFCodeGeneration\Writer\WriteInterface;
9
use Symfony\Component\Console\Tester\CommandTester;
10
11
class AddActionCommandTest extends TestCase
12
{
13
    public function testExecuteDryRun()
14
    {
15
        $writer = $this->prophesize(WriteInterface::class);
16
        $tester = new CommandTester(new AddActionCommand(null, $writer->reveal()));
17
        $tester->execute([
18
            'entity' => Hubby::class,
19
        ]);
20
21
        $display = $tester->getDisplay();
22
23
        # controller
24
        $this->assertContains('AddHubbyAction', $display);
25
        # config
26
        $this->assertContains('ConfigProvider', $display);
27
        # factories
28
        $this->assertContains('HubbyHydratorFactory', $display);
29
    }
30
31
    public function testExecuteForce()
32
    {
33
        $writer = new class implements WriteInterface {
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
34
            public $content = '';
35
36
            public function write(string $content, string $fileName): void
37
            {
38
                $this->content .= $content;
39
            }
40
        };
41
        $tester = new CommandTester(new AddActionCommand(null, $writer));
42
        $tester->execute([
43
            'entity' => Hubby::class,
44
            '--force' => true,
45
        ]);
46
47
        $content = $writer->content;
48
49
        $this->assertContains('AddHubbyAction', $content);
50
        # config
51
        $this->assertContains('ConfigProvider', $content);
52
        # factories
53
        $this->assertContains('HubbyHydratorFactory', $content);
54
    }
55
}
56