Passed
Push — master ( ed42e4...b3b06a )
by Kirill
04:44
created

HelpersTest::testVerbose()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 18
rs 9.8666
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Spiral Framework, SpiralScout LLC.
5
 *
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
declare(strict_types=1);
10
11
namespace Spiral\Tests\Console;
12
13
use Spiral\Console\StaticLocator;
14
use Spiral\Tests\Console\Fixtures\HelperCommand;
15
use Symfony\Component\Console\Output\BufferedOutput;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class HelpersTest extends BaseTest
19
{
20
    public function testVerbose(): void
21
    {
22
        $core = $this->getCore(new StaticLocator([
23
            HelperCommand::class
24
        ]));
25
26
        $actual = $core->run('helper', ['helper' => 'verbose'])
27
            ->getOutput()
28
            ->fetch();
0 ignored issues
show
Bug introduced by
The method fetch() does not exist on Symfony\Component\Console\Output\OutputInterface. It seems like you code against a sub-type of Symfony\Component\Console\Output\OutputInterface such as Symfony\Component\Console\Output\BufferedOutput. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
            ->/** @scrutinizer ignore-call */ fetch();
Loading history...
29
        $this->assertSame('false', $actual);
30
31
        $output = new BufferedOutput();
32
        $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
33
        $actual = $core->run('helper', ['helper' => 'verbose', '-v' => true], $output)
34
            ->getOutput()
35
            ->fetch();
36
37
        $this->assertSame('true', $actual);
38
    }
39
40
    public function testSprinf(): void
41
    {
42
        $core = $this->getCore(new StaticLocator([
43
            HelperCommand::class
44
        ]));
45
46
        $this->assertStringContainsString(
47
            'hello world',
48
            $core->run('helper', ['helper' => 'sprintf'])->getOutput()->fetch()
49
        );
50
    }
51
52
    public function testWriteln(): void
53
    {
54
        $core = $this->getCore(new StaticLocator([
55
            HelperCommand::class
56
        ]));
57
58
        $this->assertStringContainsString(
59
            "\n",
60
            $core->run('helper', ['helper' => 'writeln'])->getOutput()->fetch()
61
        );
62
    }
63
64
    public function testTable(): void
65
    {
66
        $core = $this->getCore(new StaticLocator([
67
            HelperCommand::class
68
        ]));
69
70
        $this->assertStringContainsString(
71
            'id',
72
            $core->run('helper', ['helper' => 'table'])->getOutput()->fetch()
73
        );
74
75
        $this->assertStringContainsString(
76
            'value',
77
            $core->run('helper', ['helper' => 'table'])->getOutput()->fetch()
78
        );
79
80
        $this->assertStringContainsString(
81
            '1',
82
            $core->run('helper', ['helper' => 'table'])->getOutput()->fetch()
83
        );
84
85
        $this->assertStringContainsString(
86
            'true',
87
            $core->run('helper', ['helper' => 'table'])->getOutput()->fetch()
88
        );
89
    }
90
}
91