RouterTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 63
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testRouter() 0 36 1
1
<?php
2
namespace Redaxscript\Tests\Bootstrap;
3
4
use Redaxscript\Bootstrap;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * RouterTest
9
 *
10
 * @since 3.1.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Bootstrap\BootstrapAbstract
17
 * @covers Redaxscript\Bootstrap\Router
18
 *
19
 * @runTestsInSeparateProcesses
20
 */
21
22
class RouterTest extends TestCaseAbstract
23
{
24
	/**
25
	 * setUp
26
	 *
27
	 * @since 5.0.0
28
	 */
29
30
	public function setUp() : void
31
	{
32
		parent::setUp();
33
		$this->_request->init();
34
	}
35
36
	/**
37
	 * testRouter
38
	 *
39
	 * @since 3.1.0
40
	 *
41
	 * @param string $route
42
	 * @param array $registryArray
43
	 * @param array $expectArray
44
	 *
45
	 * @dataProvider providerAutoloader
46
	 */
47
48
	public function testRouter(string $route = null, array $registryArray = [], array $expectArray = []) : void
49
	{
50
		/* setup */
51
52
		$this->_request->setQuery('p', $route);
53
		$this->_registry->init($registryArray);
54
		new Bootstrap\Router($this->_registry, $this->_request);
55
56
		/* actual */
57
58
		$actualArray =
59
		[
60
			'firstParameter' => $this->_registry->get('firstParameter'),
61
			'firstSubParameter' => $this->_registry->get('firstSubParameter'),
62
			'secondParameter' => $this->_registry->get('secondParameter'),
63
			'secondSubParameter' => $this->_registry->get('secondSubParameter'),
64
			'thirdParameter' => $this->_registry->get('thirdParameter'),
65
			'thirdSubParameter' => $this->_registry->get('thirdSubParameter'),
66
			'adminParameter' => $this->_registry->get('adminParameter'),
67
			'tableParameter' => $this->_registry->get('tableParameter'),
68
			'idParameter' => $this->_registry->get('idParameter'),
69
			'aliasParameter' => $this->_registry->get('aliasParameter'),
70
			'lastParameter' => $this->_registry->get('lastParameter'),
71
			'lastSubParameter' => $this->_registry->get('lastSubParameter'),
72
			'tokenParameter' => $this->_registry->get('tokenParameter'),
73
			'liteRoute' => $this->_registry->get('liteRoute'),
74
			'fullRoute' => $this->_registry->get('fullRoute'),
75
			'parameterRoute' => $this->_registry->get('parameterRoute'),
76
			'languageRoute' => $this->_registry->get('languageRoute'),
77
			'templateRoute' => $this->_registry->get('templateRoute'),
78
		];
79
80
		/* compare */
81
82
		$this->assertEquals($expectArray, $actualArray);
83
	}
84
}
85