Completed
Push — master ( 6661e3...771ea1 )
by Henry
19:40
created

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

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
use org\bovigo\vfs\vfsStream as Stream;
7
8
/**
9
 * BackupTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @requires OS Linux
18
 */
19
20
class BackupTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 3.2.0
26
	 */
27
28
	public function setUp()
29
	{
30
		parent::setUp();
31
		Stream::setup('root', 0777, $this->getProvider('tests/provider/Console/console_setup.json'));
32
	}
33
34
	/**
35
	 * tearDown
36
	 *
37
	 * @since 3.0.0
38
	 */
39
40
	public function tearDown()
41
	{
42
		$this->_request->setServer('argv', null);
43
	}
44
45
	/**
46
	 * testNoArgument
47
	 *
48
	 * @since 3.0.0
49
	 */
50
51
	public function testNoArgument()
52
	{
53
		/* setup */
54
55
		$backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config);
56
57
		/* expect and actual */
58
59
		$expect = $backupCommand->getHelp();
60
		$actual = $backupCommand->run('cli');
61
62
		/* compare */
63
64
		$this->assertEquals($expect, $actual);
65
	}
66
67
	/**
68
	 * testDatabase
69
	 *
70
	 * @since 3.0.0
71
	 */
72
73
	public function testDatabase()
74
	{
75
		/* setup */
76
77
		$this->_request->setServer('argv',
78
		[
0 ignored issues
show
array('console.php', 'ba...eam::url('root/build')) is of type array<integer,?,{"0":"st...,"3":"string","4":"?"}>, but the function expects a string|boolean|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
79
			'console.php',
80
			'backup',
81
			'database',
82
			'--directory',
83
			Stream::url('root/build')
84
		]);
85
		$backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config);
86
87
		/* actual */
88
89
		$actual = $backupCommand->run('cli');
90
91
		/* compare */
92
93
		$this->assertTrue($actual);
94
	}
95
96
	/**
97
	 * testDatabaseInvalid
98
	 *
99
	 * @since 3.0.0
100
	 */
101
102
	public function testDatabaseInvalid()
103
	{
104
		/* setup */
105
106
		$this->_request->setServer('argv',
107
		[
108
			'console.php',
109
			'backup',
110
			'database',
111
			'--no-interaction'
112
		]);
113
		$backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config);
114
115
		/* actual */
116
117
		$actual = $backupCommand->run('cli');
118
119
		/* compare */
120
121
		$this->assertFalse($actual);
122
	}
123
}
124