Completed
Push — master ( 858dca...453367 )
by Henry
06:29
created

MigrateTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests\Console\Command;
3
4
use Redaxscript\Console\Command;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * MigrateTest
9
 *
10
 * @since 4.4.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Console\Command\CommandAbstract
17
 * @covers Redaxscript\Console\Command\Migrate
18
 */
19
20
class MigrateTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 4.4.0
26
	 */
27
28
	public function setUp() : void
29
	{
30
		parent::setUp();
31
		$optionArray = $this->getOptionArray();
0 ignored issues
show
Bug introduced by redaxmedia
The method getOptionArray() does not seem to exist on object<Redaxscript\Tests...le\Command\MigrateTest>.

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...
32
		$installer = $this->installerFactory();
0 ignored issues
show
Bug introduced by redaxmedia
The method installerFactory() does not seem to exist on object<Redaxscript\Tests...le\Command\MigrateTest>.

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...
33
		$installer->init();
34
		$installer->rawCreate();
35
		$installer->insertSettings($optionArray);
36
	}
37
38
	/**
39
	 * tearDown
40
	 *
41
	 * @since 4.4.0
42
	 */
43
44
	public function tearDown() : void
45
	{
46
		$this->dropDatabase();
0 ignored issues
show
Bug introduced by redaxmedia
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests...le\Command\MigrateTest>.

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...
47
		$this->_request->setServer('argv', null);
48
	}
49
50
	/**
51
	 * testNoArgument
52
	 *
53
	 * @since 4.4.0
54
	 */
55
56
	public function testNoArgument() : void
57
	{
58
		/* setup */
59
60
		$migrateCommand = new Command\Migrate($this->_registry, $this->_request, $this->_language, $this->_config);
61
62
		/* expect and actual */
63
64
		$expect = $migrateCommand->getHelp();
65
		$actual = $migrateCommand->run('cli');
66
67
		/* compare */
68
69
		$this->assertEquals($expect, $actual);
70
	}
71
72
	/**
73
	 * testDatabase
74
	 *
75
	 * @since 4.4.0
76
	 */
77
78
	public function testDatabase() : void
79
	{
80
		/* setup */
81
82
		$this->_request->setServer('argv',
83
		[
84
			'console.php',
85
			'migrate',
86
			'database'
87
		]);
88
		$migrateCommand = new Command\Migrate($this->_registry, $this->_request, $this->_language, $this->_config);
89
90
		/* expect and actual */
91
92
		$expect = $migrateCommand->success();
93
		$actual = $migrateCommand->run('cli');
94
95
		/* compare */
96
97
		$this->assertEquals($expect, $actual);
98
	}
99
}
100