Completed
Push — master ( f0a9c0...16ddfb )
by Henry
08:56
created

tests/unit/Console/Command/InstallTest.php (4 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

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\Tests\TestCaseAbstract;
6
7
/**
8
 * InstallTest
9
 *
10
 * @since 3.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Console\Command\CommandAbstract
17
 * @covers Redaxscript\Console\Command\Install
18
 */
19
20
class InstallTest extends TestCaseAbstract
21
{
22
	/**
23
	 * tearDown
24
	 *
25
	 * @since 3.0.0
26
	 */
27
28
	public function tearDown() : void
29
	{
30
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests...le\Command\InstallTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
		$this->_request->setServer('argv', null);
32
	}
33
34
	/**
35
	 * testNoArgument
36
	 *
37
	 * @since 3.0.0
38
	 */
39
40
	public function testNoArgument() : void
41
	{
42
		/* setup */
43
44
		$installCommand = new Command\Install($this->_registry, $this->_request, $this->_language, $this->_config);
45
46
		/* expect and actual */
47
48
		$expect = $installCommand->getHelp();
49
		$actual = $installCommand->run('cli');
50
51
		/* compare */
52
53
		$this->assertEquals($expect, $actual);
54
	}
55
56
	/**
57
	 * testDatabase
58
	 *
59
	 * @since 3.0.0
60
	 */
61
62
	public function testDatabase() : void
63
	{
64
		/* setup */
65
66
		$this->_request->setServer('argv',
67
		[
68
			'console.php',
69
			'install',
70
			'database',
71
			'--admin-name',
72
			'test',
73
			'--admin-user',
74
			'test',
75
			'--admin-password',
76
			'test',
77
			'--admin-email',
78
			'[email protected]'
79
		]);
80
		$installCommand = new Command\Install($this->_registry, $this->_request, $this->_language, $this->_config);
81
82
		/* expect and actual */
83
84
		$expect = $installCommand->success();
85
		$actual = $installCommand->run('cli');
86
87
		/* compare */
88
89
		$this->assertEquals($expect, $actual);
90
	}
91
92
	/**
93
	 * testDatabaseInvalid
94
	 *
95
	 * @since 3.0.0
96
	 */
97
98
	public function testDatabaseInvalid() : void
99
	{
100
		/* setup */
101
102
		$this->_request->setServer('argv',
103
		[
104
			'console.php',
105
			'install',
106
			'database',
107
			'--no-interaction'
108
		]);
109
		$installCommand = new Command\Install($this->_registry, $this->_request, $this->_language, $this->_config);
110
111
		/* expect and actual */
112
113
		$expect = $installCommand->error();
114
		$actual = $installCommand->run('cli');
115
116
		/* compare */
117
118
		$this->assertEquals($expect, $actual);
119
	}
120
121
	/**
122
	 * testModule
123
	 *
124
	 * @since 3.0.0
125
	 */
126
127
	public function testModule() : void
128
	{
129
		/* setup */
130
131
		$this->createDatabase();
0 ignored issues
show
The method createDatabase() does not seem to exist on object<Redaxscript\Tests...le\Command\InstallTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
132
		$this->_request->setServer('argv',
133
		[
134
			'console.php',
135
			'install',
136
			'module',
137
			'--alias',
138
			'TestDummy'
139
		]);
140
		$installCommand = new Command\Install($this->_registry, $this->_request, $this->_language, $this->_config);
141
142
		/* expect and actual */
143
144
		$expect = $installCommand->success();
145
		$actual = $installCommand->run('cli');
146
147
		/* teardown */
148
149
		$this->uninstallTestDummy();
0 ignored issues
show
The method uninstallTestDummy() does not seem to exist on object<Redaxscript\Tests...le\Command\InstallTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
150
151
		/* compare */
152
153
		$this->assertEquals($expect, $actual);
154
	}
155
156
	/**
157
	 * testModule
158
	 *
159
	 * @since 3.0.0
160
	 */
161
162
	public function testModuleInvalid() : void
163
	{
164
		/* setup */
165
166
		$this->createDatabase();
0 ignored issues
show
The method createDatabase() does not seem to exist on object<Redaxscript\Tests...le\Command\InstallTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
167
		$this->_request->setServer('argv',
168
		[
169
			'console.php',
170
			'install',
171
			'module',
172
			'--no-interaction'
173
		]);
174
		$installCommand = new Command\Install($this->_registry, $this->_request, $this->_language, $this->_config);
175
176
		/* expect and actual */
177
178
		$expect = $installCommand->error();
179
		$actual = $installCommand->run('cli');
180
181
		/* compare */
182
183
		$this->assertEquals($expect, $actual);
184
	}
185
}
186