Completed
Push — master ( 113b98...ac9af8 )
by Henry
10:09
created

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

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
 */
22
23
class BackupTest extends TestCaseAbstract
24
{
25
	/**
26
	 * setUp
27
	 *
28
	 * @since 3.2.0
29
	 */
30
31
	public function setUp() : void
32
	{
33
		parent::setUp();
34
		$optionArray = $this->getOptionArray();
0 ignored issues
show
The method getOptionArray() does not seem to exist on object<Redaxscript\Tests...ole\Command\BackupTest>.

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...
35
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests...ole\Command\BackupTest>.

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...
36
		$installer->init();
37
		$installer->rawCreate();
38
		$installer->insertSettings($optionArray);
39
		Stream::setup('root', 0777, $this->getJSON('tests' . DIRECTORY_SEPARATOR . 'unit-provider' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ConsoleTest_setUp.json'));
0 ignored issues
show
The method getJSON() does not seem to exist on object<Redaxscript\Tests...ole\Command\BackupTest>.

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...
40
	}
41
42
	/**
43
	 * tearDown
44
	 *
45
	 * @since 3.0.0
46
	 */
47
48
	public function tearDown() : void
49
	{
50
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests...ole\Command\BackupTest>.

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