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

tests/unit/Router/RouterTest.php (3 issues)

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\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
 */
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\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\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
		$router = new 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 array $settingArray
94
	 * @param bool $expect
95
	 *
96
	 * @dataProvider providerAutoloader
97
	 */
98
99
	public function testContent(array $registryArray = [], array $queryArray = [], array $postArray = [], array $settingArray = [], bool $expect = null) : void
100
	{
101
		/* setup */
102
103
		$this->_registry->init($registryArray);
104
		$this->_request->set('get', $queryArray);
105
		$this->_request->set('post', $postArray);
106
		$setting = $this->settingFactory();
0 ignored issues
show
The method settingFactory() does not seem to exist on object<Redaxscript\Tests\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...
107
		$setting->set('recovery', $settingArray['recovery']);
108
		$setting->set('registration', $settingArray['registration']);
109
		$router = new Router\Router($this->_registry, $this->_request, $this->_language, $this->_config);
110
		$router->init();
111
112
		/* actual */
113
114
		$actual = $router->routeContent();
115
116
		/* compare */
117
118
		$expect ? $this->assertIsString($actual) : $this->assertNull($actual);
119
	}
120
}
121