1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\Console\Command; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Console\Command; |
5
|
|
|
use Redaxscript\Modules\TestDummy; |
6
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* UninstallTest |
10
|
|
|
* |
11
|
|
|
* @since 3.0.0 |
12
|
|
|
* |
13
|
|
|
* @package Redaxscript |
14
|
|
|
* @category Tests |
15
|
|
|
* @author Henry Ruhs |
16
|
|
|
* |
17
|
|
|
* @covers Redaxscript\Console\Command\CommandAbstract |
18
|
|
|
* @covers Redaxscript\Console\Command\Uninstall |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
class UninstallTest extends TestCaseAbstract |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* setUp |
25
|
|
|
* |
26
|
|
|
* @since 3.1.0 |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
public function setUp() : void |
30
|
|
|
{ |
31
|
|
|
parent::setUp(); |
32
|
|
|
$this->createDatabase(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* tearDown |
37
|
|
|
* |
38
|
|
|
* @since 3.1.0 |
39
|
|
|
*/ |
40
|
|
|
|
41
|
|
|
public function tearDown() : void |
42
|
|
|
{ |
43
|
|
|
$this->dropDatabase(); |
44
|
|
|
$this->_request->setServer('argv', null); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* testNoArgument |
49
|
|
|
* |
50
|
|
|
* @since 3.0.0 |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
public function testNoArgument() : void |
54
|
|
|
{ |
55
|
|
|
/* setup */ |
56
|
|
|
|
57
|
|
|
$uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
58
|
|
|
|
59
|
|
|
/* expect and actual */ |
60
|
|
|
|
61
|
|
|
$expect = $uninstallCommand->getHelp(); |
62
|
|
|
$actual = $uninstallCommand->run('cli'); |
63
|
|
|
|
64
|
|
|
/* compare */ |
65
|
|
|
|
66
|
|
|
$this->assertEquals($expect, $actual); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* testDatabase |
71
|
|
|
* |
72
|
|
|
* @since 3.0.0 |
73
|
|
|
*/ |
74
|
|
|
|
75
|
|
|
public function testDatabase() : void |
76
|
|
|
{ |
77
|
|
|
/* setup */ |
78
|
|
|
|
79
|
|
|
$this->_request->setServer('argv', |
80
|
|
|
[ |
81
|
|
|
'console.php', |
82
|
|
|
'uninstall', |
83
|
|
|
'database' |
84
|
|
|
]); |
85
|
|
|
$uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
86
|
|
|
|
87
|
|
|
/* expect and actual */ |
88
|
|
|
|
89
|
|
|
$expect = $uninstallCommand->success(); |
90
|
|
|
$actual = $uninstallCommand->run('cli'); |
91
|
|
|
|
92
|
|
|
/* compare */ |
93
|
|
|
|
94
|
|
|
$this->assertEquals($expect, $actual); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* testModule |
99
|
|
|
* |
100
|
|
|
* @since 3.0.0 |
101
|
|
|
*/ |
102
|
|
|
|
103
|
|
|
public function testModule() : void |
104
|
|
|
{ |
105
|
|
|
/* setup */ |
106
|
|
|
|
107
|
|
|
$testDummy = new TestDummy\TestDummy($this->_registry, $this->_request, $this->_language, $this->_config); |
108
|
|
|
$testDummy->install(); |
109
|
|
|
$this->_request->setServer('argv', |
110
|
|
|
[ |
111
|
|
|
'console.php', |
112
|
|
|
'uninstall', |
113
|
|
|
'module', |
114
|
|
|
'--alias', |
115
|
|
|
'TestDummy' |
116
|
|
|
]); |
117
|
|
|
$uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
118
|
|
|
|
119
|
|
|
/* expect and actual */ |
120
|
|
|
|
121
|
|
|
$expect = $uninstallCommand->success(); |
122
|
|
|
$actual = $uninstallCommand->run('cli'); |
123
|
|
|
|
124
|
|
|
/* compare */ |
125
|
|
|
|
126
|
|
|
$this->assertEquals($expect, $actual); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* testModule |
131
|
|
|
* |
132
|
|
|
* @since 3.0.0 |
133
|
|
|
*/ |
134
|
|
|
|
135
|
|
|
public function testModuleInvalid() : void |
136
|
|
|
{ |
137
|
|
|
/* setup */ |
138
|
|
|
|
139
|
|
|
$this->_request->setServer('argv', |
140
|
|
|
[ |
141
|
|
|
'console.php', |
142
|
|
|
'uninstall', |
143
|
|
|
'module', |
144
|
|
|
'--no-interaction' |
145
|
|
|
]); |
146
|
|
|
$uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
147
|
|
|
|
148
|
|
|
/* expect and actual */ |
149
|
|
|
|
150
|
|
|
$expect = $uninstallCommand->error(); |
151
|
|
|
$actual = $uninstallCommand->run('cli'); |
152
|
|
|
|
153
|
|
|
/* compare */ |
154
|
|
|
|
155
|
|
|
$this->assertEquals($expect, $actual); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|