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

tests/phpunit/Console/Command/RestoreTest.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
 * RestoreTest
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\Restore
19
 *
20
 * @requires OS Linux
21
 */
22
23
class RestoreTest extends TestCaseAbstract
24
{
25
	/**
26
	 * setUp
27
	 *
28
	 * @since 3.0.0
29
	 */
30
31
	public function setUp()
32
	{
33
		parent::setUp();
34
		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...
35
	}
36
37
	/**
38
	 * tearDown
39
	 *
40
	 * @since 3.0.0
41
	 */
42
43
	public function tearDown()
44
	{
45
		$this->dropDatabase();
46
		$this->_request->setServer('argv', null);
47
	}
48
49
	/**
50
	 * testNoArgument
51
	 *
52
	 * @since 3.0.0
53
	 */
54
55
	public function testNoArgument()
56
	{
57
		/* setup */
58
59
		$restoreCommand = new Command\Restore($this->_registry, $this->_request, $this->_language, $this->_config);
60
61
		/* expect and actual */
62
63
		$expect = $restoreCommand->getHelp();
64
		$actual = $restoreCommand->run('cli');
65
66
		/* compare */
67
68
		$this->assertEquals($expect, $actual);
69
	}
70
71
	/**
72
	 * testDatabase
73
	 *
74
	 * @since 3.0.0
75
	 */
76
77
	public function testDatabase()
78
	{
79
		/* setup */
80
81
		$this->_request->setServer('argv',
82
		[
83
			'console.php',
84
			'restore',
85
			'database',
86
			'--directory',
87
			Stream::url('root' . DIRECTORY_SEPARATOR . 'build'),
88
			'--file',
89
			'test.sql'
90
		]);
91
		$restoreCommand = new Command\Restore($this->_registry, $this->_request, $this->_language, $this->_config);
92
93
		/* expect and actual */
94
95
		$expect = $restoreCommand->success();
96
		$actual = $restoreCommand->run('cli');
97
98
		/* compare */
99
100
		$this->assertEquals($expect, $actual);
101
	}
102
103
	/**
104
	 * testDatabaseInvalid
105
	 *
106
	 * @since 3.0.0
107
	 */
108
109
	public function testDatabaseInvalid()
110
	{
111
		/* setup */
112
113
		$this->_request->setServer('argv',
114
		[
115
			'console.php',
116
			'restore',
117
			'database',
118
			'--no-interaction'
119
		]);
120
		$restoreCommand = new Command\Restore($this->_registry, $this->_request, $this->_language, $this->_config);
121
122
		/* expect and actual */
123
124
		$expect = $restoreCommand->error();
125
		$actual = $restoreCommand->run('cli');
126
127
		/* compare */
128
129
		$this->assertEquals($expect, $actual);
130
	}
131
}
132