Completed
Push — master ( cbd317...231b94 )
by Henry
09:43
created

tests/phpunit/Console/Command/BackupTest.php (1 issue)

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 org\bovigo\vfs\vfsStream as Stream;
5
use Redaxscript\Console\Command;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * BackupTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Console\Command\Backup
18
 * @covers Redaxscript\Console\Command\CommandAbstract
19
 *
20
 * @requires OS Linux
21
 * @requires PHP 7.2
22
 */
23
24
class BackupTest extends TestCaseAbstract
25
{
26
	/**
27
	 * setUp
28
	 *
29
	 * @since 3.2.0
30
	 */
31
32
	public function setUp()
33
	{
34
		parent::setUp();
35
		$optionArray =
36
		[
37
			'adminName' => 'Test',
38
			'adminUser' => 'test',
39
			'adminPassword' => 'test',
40
			'adminEmail' => '[email protected]'
41
		];
42
		$installer = $this->installerFactory();
43
		$installer->init();
44
		$installer->rawCreate();
45
		$installer->insertSettings($optionArray);
46
		Stream::setup('root', 0777, $this->getJSON('tests' . DIRECTORY_SEPARATOR . 'provider' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ConsoleTest_setUp.json'));
0 ignored issues
show
It seems like $this->getJSON('tests' ....onsoleTest_setUp.json') targeting Redaxscript\Tests\TestCaseAbstract::getJSON() can also be of type null; however, org\bovigo\vfs\vfsStream::setup() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
47
	}
48
49
	/**
50
	 * tearDown
51
	 *
52
	 * @since 3.0.0
53
	 */
54
55
	public function tearDown()
56
	{
57
		$this->dropDatabase();
58
		$this->_request->setServer('argv', null);
59
	}
60
61
	/**
62
	 * testNoArgument
63
	 *
64
	 * @since 3.0.0
65
	 */
66
67
	public function testNoArgument()
68
	{
69
		/* setup */
70
71
		$backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config);
72
73
		/* expect and actual */
74
75
		$expect = $backupCommand->getHelp();
76
		$actual = $backupCommand->run('cli');
77
78
		/* compare */
79
80
		$this->assertEquals($expect, $actual);
81
	}
82
83
	/**
84
	 * testDatabase
85
	 *
86
	 * @since 3.0.0
87
	 */
88
89
	public function testDatabase()
90
	{
91
		/* setup */
92
93
		$this->_request->setServer('argv',
94
		[
95
			'console.php',
96
			'backup',
97
			'database',
98
			'--directory',
99
			Stream::url('root' . DIRECTORY_SEPARATOR . 'build')
100
		]);
101
		$backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config);
102
103
		/* expect and actual */
104
105
		$expect = $backupCommand->success();
106
		$actual = $backupCommand->run('cli');
107
108
		/* compare */
109
110
		$this->assertEquals($expect, $actual);
111
	}
112
113
	/**
114
	 * testDatabaseInvalid
115
	 *
116
	 * @since 3.0.0
117
	 */
118
119
	public function testDatabaseInvalid()
120
	{
121
		/* setup */
122
123
		$this->_request->setServer('argv',
124
		[
125
			'console.php',
126
			'backup',
127
			'database',
128
			'--no-interaction'
129
		]);
130
		$backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config);
131
132
		/* expect and actual */
133
134
		$expect = $backupCommand->error();
135
		$actual = $backupCommand->run('cli');
136
137
		/* compare */
138
139
		$this->assertEquals($expect, $actual);
140
	}
141
}
142