Completed
Push — master ( 01f593...6661e3 )
by Henry
10:15
created

RouterTest::testHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
namespace Redaxscript\Tests\Router;
3
4
use Redaxscript\Router;
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
17
class RouterTest extends TestCaseAbstract
18
{
19
	/**
20
	 * setUp
21
	 *
22
	 * @since 3.3.0
23
	 */
24
25
	public function setUp()
26
	{
27
		parent::setUp();
28
		$installer = $this->installerFactory();
29
		$installer->init();
30
		$installer->rawCreate();
31
		$installer->insertSettings(
32
		[
33
			'adminName' => 'Test',
34
			'adminUser' => 'test',
35
			'adminPassword' => 'test',
36
			'adminEmail' => '[email protected]'
37
		]);
38
		$installer->insertUsers(
39
		[
40
			'adminName' => 'Test',
41
			'adminUser' => 'test',
42
			'adminPassword' => 'test',
43
			'adminEmail' => '[email protected]'
44
		]);
45
	}
46
47
	/**
48
	 * tearDown
49
	 *
50
	 * @since 3.3.0
51
	 */
52
53
	public function tearDown()
54
	{
55
		$installer = $this->installerFactory();
56
		$installer->init();
57
		$installer->rawDrop();
58
	}
59
60
	/**
61
	 * providerHeader
62
	 *
63
	 * @since 3.3.0
64
	 *
65
	 * @return array
66
	 */
67
68
	public function providerHeader() : array
69
	{
70
		return $this->getProvider('tests/provider/Router/router_header.json');
71
	}
72
73
	/**
74
	 * providerContent
75
	 *
76
	 * @since 3.3.0
77
	 *
78
	 * @return array
79
	 */
80
81
	public function providerContent() : array
82
	{
83
		return $this->getProvider('tests/provider/Router/router_content.json');
84
	}
85
86
	/**
87
	 * testHeader
88
	 *
89
	 * @since 3.3.0
90
	 *
91
	 * @param array $registryArray
92
	 * @param array $postArray
93
	 * @param bool $expect
94
	 *
95
	 * @dataProvider providerHeader
96
	 */
97
98
	public function testHeader(array $registryArray = [], array $postArray = [], bool $expect = null)
99
	{
100
		/* setup */
101
102
		$this->_registry->init($registryArray);
103
		$this->_request->set('post', $postArray);
104
		$router = new Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
105
		$router->init();
106
107
		/* actual */
108
109
		$actual = $router->routeHeader();
110
111
		/* compare */
112
113
		$this->assertEquals($expect, $actual);
114
	}
115
116
	/**
117
	 * testContent
118
	 *
119
	 * @since 3.3.0
120
	 *
121
	 * @param array $registryArray
122
	 * @param array $queryArray
123
	 * @param array $postArray
124
	 * @param bool $expect
125
	 *
126
	 * @dataProvider providerContent
127
	 */
128
129
	public function testContent(array $registryArray = [], array $queryArray = [], array $postArray = [], bool $expect = null)
130
	{
131
		/* setup */
132
133
		$this->_registry->init($registryArray);
134
		$this->_request->set('get', $queryArray);
135
		$this->_request->set('post', $postArray);
136
		$router = new Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
137
		$router->init();
138
139
		/* actual */
140
141
		$actual = $router->routeContent();
142
143
		/* compare */
144
145
		$expect ? $this->assertString($actual) : $this->assertFalse($actual);
146
	}
147
}