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(); |
|
|
|
|
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
|
|
|
|