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

tests/unit/Admin/Router/RouterTest.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\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 = $this->getOptionArray();
0 ignored issues
show
The method getOptionArray() 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...
31
		$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...
32
		$installer->init();
33
		$installer->rawCreate();
34
		$installer->insertSettings($optionArray);
35
		$installer->insertUsers($optionArray);
36
	}
37
38
	/**
39
	 * tearDown
40
	 *
41
	 * @since 3.3.0
42
	 */
43
44
	public function tearDown() : void
45
	{
46
		$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...
47
	}
48
49
	/**
50
	 * testHeader
51
	 *
52
	 * @since 3.3.0
53
	 *
54
	 * @param array $registryArray
55
	 * @param array $postArray
56
	 * @param bool $expect
57
	 *
58
	 * @dataProvider providerAutoloader
59
	 */
60
61
	public function testHeader(array $registryArray = [], array $postArray = [], bool $expect = null) : void
62
	{
63
		/* setup */
64
65
		$this->_registry->init($registryArray);
66
		$this->_request->set('post', $postArray);
67
		$this->_request->set('server',
68
		[
69
			'HTTP_HOST' => 'localhost',
70
			'HTTP_USER_AGENT' => 'redaxscript',
71
			'REMOTE_ADDR' => 'localhost'
72
		]);
73
		$router = new Admin\Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
74
		$router->init();
75
76
		/* actual */
77
78
		$actual = $router->routeHeader();
79
80
		/* compare */
81
82
		$this->assertEquals($expect, $actual);
83
	}
84
85
	/**
86
	 * testContent
87
	 *
88
	 * @since 3.3.0
89
	 *
90
	 * @param array $registryArray
91
	 * @param array $queryArray
92
	 * @param array $postArray
93
	 * @param bool $expect
94
	 *
95
	 * @dataProvider providerAutoloader
96
	 */
97
98
	public function testContent(array $registryArray = [], array $queryArray = [], array $postArray = [], bool $expect = null) : void
99
	{
100
		/* setup */
101
102
		$this->_registry->init($registryArray);
103
		$this->_request->set('get', $queryArray);
104
		$this->_request->set('post', $postArray);
105
		$router = new Admin\Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
106
		$router->init();
107
108
		/* actual */
109
110
		$actual = $router->routeContent();
111
112
		/* compare */
113
114
		$expect ? $this->assertIsString($actual) : $this->assertNull($actual);
115
	}
116
}
117