RouterTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 96
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A tearDown() 0 4 1
A testHeader() 0 17 1
A testContent() 0 21 2
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
 * @covers Redaxscript\Router\Router
17
 * @covers Redaxscript\Router\RouterAbstract
18
 */
19
20
class RouterTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 3.3.0
26
	 */
27
28
	public function setUp() : void
29
	{
30
		parent::setUp();
31
		$optionArray = $this->getOptionArray();
32
		$installer = $this->installerFactory();
33
		$installer->init();
34
		$installer->rawCreate();
35
		$installer->insertSettings($optionArray);
36
		$installer->insertUsers($optionArray);
37
	}
38
39
	/**
40
	 * tearDown
41
	 *
42
	 * @since 3.3.0
43
	 */
44
45
	public function tearDown() : void
46
	{
47
		$this->dropDatabase();
48
	}
49
50
	/**
51
	 * testHeader
52
	 *
53
	 * @since 3.3.0
54
	 *
55
	 * @param array $registryArray
56
	 * @param array $postArray
57
	 * @param bool $expect
58
	 *
59
	 * @dataProvider providerAutoloader
60
	 */
61
62
	public function testHeader(array $registryArray = [], array $postArray = [], bool $expect = null) : void
63
	{
64
		/* setup */
65
66
		$this->_registry->init($registryArray);
67
		$this->_request->set('post', $postArray);
68
		$router = new Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
69
		$router->init();
70
71
		/* actual */
72
73
		$actual = $router->routeHeader();
74
75
		/* compare */
76
77
		$this->assertEquals($expect, $actual);
78
	}
79
80
	/**
81
	 * testContent
82
	 *
83
	 * @since 3.3.0
84
	 *
85
	 * @param array $registryArray
86
	 * @param array $queryArray
87
	 * @param array $postArray
88
	 * @param array $settingArray
89
	 * @param bool $expect
90
	 *
91
	 * @dataProvider providerAutoloader
92
	 */
93
94
	public function testContent(array $registryArray = [], array $queryArray = [], array $postArray = [], array $settingArray = [], bool $expect = null) : void
95
	{
96
		/* setup */
97
98
		$this->_registry->init($registryArray);
99
		$this->_request->set('get', $queryArray);
100
		$this->_request->set('post', $postArray);
101
		$setting = $this->settingFactory();
102
		$setting->set('recovery', $settingArray['recovery']);
103
		$setting->set('registration', $settingArray['registration']);
104
		$router = new Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
105
		$router->init();
106
107
		/* actual */
108
109
		$actual = $router->routeContent();
110
111
		/* compare */
112
113
		$expect ? $this->assertIsString($actual) : $this->assertNull($actual);
114
	}
115
}
116