Completed
Push — master ( 1da492...320203 )
by Henry
07:00
created

tests/unit/Admin/Controller/ModuleTest.php (3 issues)

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\Admin\Controller;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Db;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * ModuleTest
10
 *
11
 * @since 4.1.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Admin\Controller\Module
18
 * @covers Redaxscript\Admin\Controller\ControllerAbstract
19
 */
20
21
class ModuleTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 4.1.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$optionArray = $this->getOptionArray();
0 ignored issues
show
The method getOptionArray() does not seem to exist on object<Redaxscript\Tests...\Controller\ModuleTest>.

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

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...
34
		$installer->init();
35
		$installer->rawCreate();
36
		$installer->insertSettings($optionArray);
37
		Db::forTablePrefix('modules')
38
			->create()
39
			->set(
40
			[
41
				'name' => 'Module One',
42
				'alias' => 'ModuleOne'
43
			])
44
			->save();
45
	}
46
47
	/**
48
	 * tearDown
49
	 *
50
	 * @since 4.1.0
51
	 */
52
53
	public function tearDown() : void
54
	{
55
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests...\Controller\ModuleTest>.

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...
56
	}
57
58
	/**
59
	 * testUpdate
60
	 *
61
	 * @since 4.1.0
62
	 *
63
	 * @param array $registryArray
64
	 * @param array $postArray
65
	 * @param string $expect
66
	 *
67
	 * @dataProvider providerAutoloader
68
	 */
69
70
	public function testUpdate(array $registryArray = [], array $postArray = [], string $expect = null) : void
71
	{
72
		/* setup */
73
74
		$this->_registry->init($registryArray);
75
		$this->_request->set('post', $postArray);
76
		$moduleController = new Admin\Controller\Module($this->_registry, $this->_request, $this->_language, $this->_config);
77
78
		/* actual */
79
80
		$actual = $moduleController->process('update');
81
82
		/* compare */
83
84
		$this->assertEquals($expect, $actual);
85
	}
86
87
	/**
88
	 * testInvalid
89
	 *
90
	 * @since 4.1.0
91
	 *
92
	 * @param array $registryArray
93
	 * @param array $postArray
94
	 * @param string $expect
95
	 *
96
	 * @dataProvider providerAutoloader
97
	 */
98
99
	public function testInvalid(array $registryArray = [], array $postArray = [], string $expect = null) : void
100
	{
101
		/* setup */
102
103
		$this->_registry->init($registryArray);
104
		$this->_request->set('post', $postArray);
105
		$moduleController = new Admin\Controller\Module($this->_registry, $this->_request, $this->_language, $this->_config);
106
107
		/* actual */
108
109
		$actual = $moduleController->process('invalid');
110
111
		/* compare */
112
113
		$this->assertEquals($expect, $actual);
114
	}
115
}
116