HelloWorldCommandTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Test\Commands;
4
5
use App\Commands\HelloWorldCommand;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Console\Application;
8
use Symfony\Component\Console\Tester\CommandTester;
9
10
class HelloWorldCommandTest extends TestCase
11
{
12
    /**
13
     * @var Application
14
     */
15
    private $application;
16
17
    public function testHelloWorld()
18
    {
19
        $expected = "Hello, world!\n";
20
        $commandName = 'hello-world';
21
        $command = $this->application->find($commandName);
22
        $commandTester = new CommandTester($command);
23
        $commandTester->execute(['command' => $commandName]);
24
        $output = $commandTester->getDisplay();
25
        $this->assertSame($expected, $output);
26
    }
27
28
    protected function setUp()
29
    {
30
        $command = new HelloWorldCommand();
31
        $this->application = new Application();
32
        $this->application->add($command);
33
    }
34
}
35