These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | |||
18 | class UninstallTest extends TestCaseAbstract |
||
19 | { |
||
20 | /** |
||
21 | * setUp |
||
22 | * |
||
23 | * @since 3.1.0 |
||
24 | */ |
||
25 | |||
26 | public function setUp() |
||
27 | { |
||
28 | parent::setUp(); |
||
29 | $installer = $this->installerFactory(); |
||
30 | $installer->init(); |
||
31 | $installer->rawCreate(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * tearDown |
||
36 | * |
||
37 | * @since 3.1.0 |
||
38 | */ |
||
39 | |||
40 | public function tearDown() |
||
41 | { |
||
42 | $installer = $this->installerFactory(); |
||
43 | $installer->init(); |
||
44 | $installer->rawDrop(); |
||
45 | $this->_request->setServer('argv', null); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * testNoArgument |
||
50 | * |
||
51 | * @since 3.0.0 |
||
52 | */ |
||
53 | |||
54 | public function testNoArgument() |
||
55 | { |
||
56 | /* setup */ |
||
57 | |||
58 | $uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
||
59 | |||
60 | /* expect and actual */ |
||
61 | |||
62 | $expect = $uninstallCommand->getHelp(); |
||
63 | $actual = $uninstallCommand->run('cli'); |
||
64 | |||
65 | /* compare */ |
||
66 | |||
67 | $this->assertEquals($expect, $actual); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * testDatabase |
||
72 | * |
||
73 | * @since 3.0.0 |
||
74 | */ |
||
75 | |||
76 | public function testDatabase() |
||
77 | { |
||
78 | /* setup */ |
||
79 | |||
80 | $this->_request->setServer('argv', |
||
81 | [ |
||
82 | 'console.php', |
||
83 | 'uninstall', |
||
84 | 'database' |
||
85 | ]); |
||
86 | $uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
||
87 | |||
88 | /* actual */ |
||
89 | |||
90 | $actual = $uninstallCommand->run('cli'); |
||
91 | |||
92 | /* compare */ |
||
93 | |||
94 | $this->assertTrue($actual); |
||
0 ignored issues
–
show
|
|||
95 | } |
||
96 | |||
97 | /** |
||
98 | * testModule |
||
99 | * |
||
100 | * @since 3.0.0 |
||
101 | */ |
||
102 | |||
103 | public function testModule() |
||
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 | /* actual */ |
||
120 | |||
121 | $actual = $uninstallCommand->run('cli'); |
||
122 | |||
123 | /* compare */ |
||
124 | |||
125 | $this->assertTrue($actual); |
||
0 ignored issues
–
show
It seems like
$actual defined by $uninstallCommand->run('cli') on line 121 can also be of type null or string ; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
|
|||
126 | } |
||
127 | |||
128 | /** |
||
129 | * testModule |
||
130 | * |
||
131 | * @since 3.0.0 |
||
132 | */ |
||
133 | |||
134 | public function testModuleInvalid() |
||
135 | { |
||
136 | /* setup */ |
||
137 | |||
138 | $this->_request->setServer('argv', |
||
139 | [ |
||
140 | 'console.php', |
||
141 | 'uninstall', |
||
142 | 'module', |
||
143 | '--no-interaction' |
||
144 | ]); |
||
145 | $uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_language, $this->_config); |
||
146 | |||
147 | /* actual */ |
||
148 | |||
149 | $actual = $uninstallCommand->run('cli'); |
||
150 | |||
151 | /* compare */ |
||
152 | |||
153 | $this->assertFalse($actual); |
||
0 ignored issues
–
show
It seems like
$actual defined by $uninstallCommand->run('cli') on line 149 can also be of type null or string ; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
|
|||
154 | } |
||
155 | } |
||
156 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.