|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace sebastianfeldmann\CaptainHook\Console\IO; |
|
4
|
|
|
|
|
5
|
|
|
class ComposerIOTest extends \PHPUnit_Framework_TestCase |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var \sebastianfeldmann\CaptainHook\Console\IO; |
|
9
|
|
|
*/ |
|
10
|
|
|
private $io; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Test setup |
|
14
|
|
|
*/ |
|
15
|
|
|
public function setUp() |
|
16
|
|
|
{ |
|
17
|
|
|
$mock = $this->getMockBuilder('\\Composer\\IO\\IOInterface') |
|
18
|
|
|
->disableOriginalConstructor() |
|
19
|
|
|
->getMock(); |
|
20
|
|
|
$mock->method('isInteractive')->willReturn(false); |
|
21
|
|
|
$mock->method('isDebug')->willReturn(false); |
|
22
|
|
|
$mock->method('isVerbose')->willReturn(false); |
|
23
|
|
|
$mock->method('isVeryVerbose')->willReturn(false); |
|
24
|
|
|
$mock->method('ask')->willReturn('bar'); |
|
25
|
|
|
$mock->method('askConfirmation')->willReturn(true); |
|
26
|
|
|
$mock->method('askAndValidate')->willReturn(true); |
|
27
|
|
|
$this->io = new ComposerIO($mock); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Test tear down |
|
32
|
|
|
*/ |
|
33
|
|
|
public function tearDown() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->io = null; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Tests ComposerIO::isInteractive |
|
40
|
|
|
*/ |
|
41
|
|
|
public function testIsInteractive() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->assertFalse($this->io->isInteractive()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Tests ComposerIO::isDebug |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testIsDebug() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->assertFalse($this->io->isDebug()); |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Tests ComposerIO::isVerbose |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testIsVerbose() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->assertFalse($this->io->isVerbose()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Tests ComposerIO::isVeryVerbose |
|
65
|
|
|
*/ |
|
66
|
|
|
public function testIsVeryVerbose() |
|
67
|
|
|
{ |
|
68
|
|
|
$this->assertFalse($this->io->isVeryVerbose()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Tests ComposerIO::write |
|
73
|
|
|
*/ |
|
74
|
|
|
public function testWrite() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->io->write('foo'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Tests ComposerIO::writeError |
|
81
|
|
|
*/ |
|
82
|
|
|
public function testWriteError() |
|
83
|
|
|
{ |
|
84
|
|
|
$this->io->writeError('foo'); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Tests ComposerIO::ask |
|
89
|
|
|
*/ |
|
90
|
|
|
public function testAsk() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->assertEquals('bar', $this->io->ask('foo', 'bar')); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Tests ComposerIO::askConfirmation |
|
97
|
|
|
*/ |
|
98
|
|
|
public function testAskConfirmation() |
|
99
|
|
|
{ |
|
100
|
|
|
$this->assertEquals(true, $this->io->askConfirmation('foo', true)); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Tests ComposerIO::askAbdValidate |
|
105
|
|
|
*/ |
|
106
|
|
|
public function testAskAndValidate() |
|
107
|
|
|
{ |
|
108
|
|
|
$this->assertEquals( |
|
109
|
|
|
true, |
|
110
|
|
|
$this->io->askAndValidate( |
|
111
|
|
|
'foo', |
|
112
|
|
|
function() { |
|
113
|
|
|
return true; |
|
114
|
|
|
}, |
|
115
|
|
|
null, |
|
116
|
|
|
true |
|
117
|
|
|
) |
|
118
|
|
|
); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|