|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of CaptainHook |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace CaptainHook\App\Console\IO; |
|
13
|
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
|
15
|
|
|
|
|
16
|
|
|
class CollectorIOTest extends TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
use Mockery; |
|
19
|
|
|
|
|
20
|
|
|
public function testGetArguments(): void |
|
21
|
|
|
{ |
|
22
|
|
|
$io = new NullIO(); |
|
23
|
|
|
$cio = new CollectorIO($io); |
|
24
|
|
|
$this->assertEquals([], $cio->getArguments()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testGetArgument(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$io = new NullIO(); |
|
30
|
|
|
$cio = new CollectorIO($io); |
|
31
|
|
|
$this->assertEquals('', $cio->getArgument('foo')); |
|
32
|
|
|
$this->assertEquals('bar', $cio->getArgument('foo', 'bar')); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testGetStandardInput(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$io = new NullIO(); |
|
38
|
|
|
$cio = new CollectorIO($io); |
|
39
|
|
|
$this->assertEquals([], $cio->getStandardInput()); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testIsInteractive(): void |
|
43
|
|
|
{ |
|
44
|
|
|
$io = new NullIO(); |
|
45
|
|
|
$cio = new CollectorIO($io); |
|
46
|
|
|
$this->assertFalse($cio->isInteractive()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testIsDebug(): void |
|
50
|
|
|
{ |
|
51
|
|
|
$io = new NullIO(); |
|
52
|
|
|
$cio = new CollectorIO($io); |
|
53
|
|
|
$this->assertFalse($cio->isDebug()); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testIsVerbose(): void |
|
57
|
|
|
{ |
|
58
|
|
|
$io = new NullIO(); |
|
59
|
|
|
$cio = new CollectorIO($io); |
|
60
|
|
|
$this->assertFalse($cio->isVerbose()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testIsVeryVerbose(): void |
|
64
|
|
|
{ |
|
65
|
|
|
$io = new NullIO(); |
|
66
|
|
|
$cio = new CollectorIO($io); |
|
67
|
|
|
$this->assertFalse($cio->isVeryVerbose()); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function testWriteError(): void |
|
71
|
|
|
{ |
|
72
|
|
|
$io = new NullIO(); |
|
73
|
|
|
$cio = new CollectorIO($io); |
|
74
|
|
|
$cio->writeError('foo'); |
|
75
|
|
|
$this->assertTrue(true); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function testAsk(): void |
|
79
|
|
|
{ |
|
80
|
|
|
$io = new NullIO(); |
|
81
|
|
|
$cio = new CollectorIO($io); |
|
82
|
|
|
$this->assertEquals('bar', $cio->ask('foo', 'bar')); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function testAskConfirmation(): void |
|
86
|
|
|
{ |
|
87
|
|
|
$io = new NullIO(); |
|
88
|
|
|
$cio = new CollectorIO($io); |
|
89
|
|
|
$this->assertEquals(true, $cio->askConfirmation('foo', true)); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function testAskAndValidate(): void |
|
93
|
|
|
{ |
|
94
|
|
|
$io = new NullIO(); |
|
95
|
|
|
$cio = new CollectorIO($io); |
|
96
|
|
|
$this->assertTrue( |
|
97
|
|
|
$cio->askAndValidate( |
|
98
|
|
|
'foo', |
|
99
|
|
|
function () { |
|
100
|
|
|
return true; |
|
101
|
|
|
}, |
|
102
|
|
|
false, |
|
103
|
|
|
true |
|
104
|
|
|
) |
|
105
|
|
|
); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|