Completed
Push — master ( 16ddfb...0ea243 )
by Henry
09:18
created

tests/unit/Admin/Router/RouterTest.php (2 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\Router;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * RouterTest
9
 *
10
 * @since 3.3.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Admin\Router\Router
17
 */
18
19
class RouterTest extends TestCaseAbstract
20
{
21
	/**
22
	 * setUp
23
	 *
24
	 * @since 3.3.0
25
	 */
26
27
	public function setUp() : void
28
	{
29
		parent::setUp();
30
		$optionArray =
31
		[
32
			'adminName' => 'Test',
33
			'adminUser' => 'test',
34
			'adminPassword' => 'test',
35
			'adminEmail' => '[email protected]'
36
		];
37
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\Admin\Router\RouterTest>.

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...
38
		$installer->init();
39
		$installer->rawCreate();
40
		$installer->insertSettings($optionArray);
41
		$installer->insertUsers($optionArray);
42
	}
43
44
	/**
45
	 * tearDown
46
	 *
47
	 * @since 3.3.0
48
	 */
49
50
	public function tearDown() : void
51
	{
52
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\Admin\Router\RouterTest>.

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...
53
	}
54
55
	/**
56
	 * testHeader
57
	 *
58
	 * @since 3.3.0
59
	 *
60
	 * @param array $registryArray
61
	 * @param array $postArray
62
	 * @param bool $expect
63
	 *
64
	 * @dataProvider providerAutoloader
65
	 */
66
67
	public function testHeader(array $registryArray = [], array $postArray = [], bool $expect = null) : void
68
	{
69
		/* setup */
70
71
		$this->_registry->init($registryArray);
72
		$this->_request->set('post', $postArray);
73
		$this->_request->set('server',
74
		[
75
			'HTTP_HOST' => 'localhost',
76
			'HTTP_USER_AGENT' => 'redaxscript',
77
			'REMOTE_ADDR' => 'localhost'
78
		]);
79
		$router = new Admin\Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
80
		$router->init();
81
82
		/* actual */
83
84
		$actual = $router->routeHeader();
85
86
		/* compare */
87
88
		$this->assertEquals($expect, $actual);
89
	}
90
91
	/**
92
	 * testContent
93
	 *
94
	 * @since 3.3.0
95
	 *
96
	 * @param array $registryArray
97
	 * @param array $queryArray
98
	 * @param array $postArray
99
	 * @param bool $expect
100
	 *
101
	 * @dataProvider providerAutoloader
102
	 */
103
104
	public function testContent(array $registryArray = [], array $queryArray = [], array $postArray = [], bool $expect = null) : void
105
	{
106
		/* setup */
107
108
		$this->_registry->init($registryArray);
109
		$this->_request->set('get', $queryArray);
110
		$this->_request->set('post', $postArray);
111
		$router = new Admin\Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
112
		$router->init();
113
114
		/* actual */
115
116
		$actual = $router->routeContent();
117
118
		/* compare */
119
120
		$expect ? $this->assertIsString($actual) : $this->assertNull($actual);
121
	}
122
}
123