1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the LGPL. For more information please see |
18
|
|
|
* <http://phing.info>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Phing\Test\Task\Optional; |
22
|
|
|
|
23
|
|
|
use Phing\Task\Optional\SymfonyConsoleArg; |
24
|
|
|
use Phing\Task\Optional\SymfonyConsoleTask; |
25
|
|
|
use PHPUnit\Framework\TestCase; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Test class for the SymfonyConsoleTask. |
29
|
|
|
* |
30
|
|
|
* @author Nuno Costa <[email protected]> |
31
|
|
|
* |
32
|
|
|
* @internal |
33
|
|
|
*/ |
34
|
|
|
class SymfonyConsoleTest extends TestCase |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var SymfonyConsoleTask |
38
|
|
|
*/ |
39
|
|
|
protected $object; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Sets up the fixture, for example, opens a network connection. |
43
|
|
|
* This method is called before a test is executed. |
44
|
|
|
*/ |
45
|
|
|
protected function setUp(): void |
46
|
|
|
{ |
47
|
|
|
$this->object = new SymfonyConsoleTask(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @covers SymfonyConsoleTask::getCommand |
52
|
|
|
* @covers SymfonyConsoleTask::setCommand |
53
|
|
|
*/ |
54
|
|
|
public function testSetGetCommand(): void |
55
|
|
|
{ |
56
|
|
|
$o = $this->object; |
57
|
|
|
$o->setCommand('foo'); |
58
|
|
|
$this->assertEquals('foo', $o->getCommand()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @covers SymfonyConsoleTask::getConsole |
63
|
|
|
* @covers SymfonyConsoleTask::setConsole |
64
|
|
|
*/ |
65
|
|
|
public function testSetGetConsole(): void |
66
|
|
|
{ |
67
|
|
|
$o = $this->object; |
68
|
|
|
$o->setConsole('foo'); |
69
|
|
|
$this->assertEquals('foo', $o->getConsole()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @covers SymfonyConsoleTask::getDebug |
74
|
|
|
* @covers SymfonyConsoleTask::setDebug |
75
|
|
|
*/ |
76
|
|
|
public function testSetGetDebug(): void |
77
|
|
|
{ |
78
|
|
|
$o = $this->object; |
79
|
|
|
$o->setDebug(false); |
80
|
|
|
$this->assertEquals(false, $o->getDebug()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @covers SymfonyConsoleTask::getSilent |
85
|
|
|
* @covers SymfonyConsoleTask::setSilent |
86
|
|
|
*/ |
87
|
|
|
public function testSetGetSilent(): void |
88
|
|
|
{ |
89
|
|
|
$o = $this->object; |
90
|
|
|
$o->setSilent(true); |
91
|
|
|
$this->assertTrue($o->getSilent()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @covers SymfonyConsoleTask::createArg |
96
|
|
|
*/ |
97
|
|
|
public function testCreateArg(): void |
98
|
|
|
{ |
99
|
|
|
$o = $this->object; |
100
|
|
|
$arg = $o->createArg(); |
101
|
|
|
$this->assertInstanceOf(SymfonyConsoleArg::class, $arg); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @covers SymfonyConsoleTask::getArgs |
106
|
|
|
*/ |
107
|
|
|
public function testGetArgs(): void |
108
|
|
|
{ |
109
|
|
|
$o = $this->object; |
110
|
|
|
$o->createArg(); |
111
|
|
|
$o->createArg(); |
112
|
|
|
$o->createArg(); |
113
|
|
|
$this->assertCount(3, $o->getArgs()); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @covers SymfonyConsoleTask::getCmdString |
118
|
|
|
*/ |
119
|
|
|
public function testGetCmdString(): void |
120
|
|
|
{ |
121
|
|
|
$o = $this->object; |
122
|
|
|
$arg = $o->createArg(); |
123
|
|
|
$arg->setName('name'); |
124
|
|
|
$arg->setValue('value'); |
125
|
|
|
|
126
|
|
|
$o->setCommand('command'); |
127
|
|
|
$o->setConsole('console'); |
128
|
|
|
|
129
|
|
|
$ret = 'console command --name=value'; |
130
|
|
|
|
131
|
|
|
$this->assertEquals($ret, $o->getCmdString()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @covers SymfonyConsoleTask::getCmdString |
136
|
|
|
*/ |
137
|
|
|
public function testNoDebugGetCmdString(): void |
138
|
|
|
{ |
139
|
|
|
$o = $this->object; |
140
|
|
|
$arg = $o->createArg(); |
141
|
|
|
$arg->setName('name'); |
142
|
|
|
$arg->setValue('value'); |
143
|
|
|
|
144
|
|
|
$o->setCommand('command'); |
145
|
|
|
$o->setConsole('console'); |
146
|
|
|
$o->setDebug(false); |
147
|
|
|
|
148
|
|
|
$ret = 'console command --name=value --no-debug'; |
149
|
|
|
|
150
|
|
|
$this->assertEquals($ret, $o->getCmdString()); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @covers SymfonyConsoleTask::getCmdString |
155
|
|
|
*/ |
156
|
|
|
public function testNoDebugOnlyOnce(): void |
157
|
|
|
{ |
158
|
|
|
$o = $this->object; |
159
|
|
|
$arg = $o->createArg(); |
160
|
|
|
$arg->setName('no-debug'); |
161
|
|
|
|
162
|
|
|
$o->setCommand('command'); |
163
|
|
|
$o->setConsole('console'); |
164
|
|
|
$o->setDebug(false); |
165
|
|
|
|
166
|
|
|
$ret = 'console command --no-debug'; |
167
|
|
|
|
168
|
|
|
$this->assertEquals($ret, $o->getCmdString()); |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|