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

tests/unit/Bootstrap/AuthTest.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\Bootstrap;
3
4
use Redaxscript\Auth;
5
use Redaxscript\Bootstrap;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * AuthTest
10
 *
11
 * @since 3.1.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Bootstrap\Auth
18
 * @covers Redaxscript\Bootstrap\BootstrapAbstract
19
 *
20
 * @runTestsInSeparateProcesses
21
 */
22
23
class AuthTest extends TestCaseAbstract
24
{
25
	/**
26
	 * setUp
27
	 *
28
	 * @since 3.1.0
29
	 */
30
31
	public function setUp() : void
32
	{
33
		parent::setUp();
34
		$optionArray = $this->getOptionArray();
0 ignored issues
show
The method getOptionArray() does not seem to exist on object<Redaxscript\Tests\Bootstrap\AuthTest>.

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...
35
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\Bootstrap\AuthTest>.

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...
36
		$installer->init();
37
		$installer->rawCreate();
38
		$installer->insertUsers($optionArray);
39
		$installer->insertGroups();
40
	}
41
42
	/**
43
	 * tearDown
44
	 *
45
	 * @since 3.1.0
46
	 */
47
48
	public function tearDown() : void
49
	{
50
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\Bootstrap\AuthTest>.

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...
51
	}
52
53
	/**
54
	 * testAuth
55
	 *
56
	 * @since 3.1.0
57
	 *
58
	 * @param int $userId
59
	 * @param array $expectArray
60
	 *
61
	 * @dataProvider providerAutoloader
62
	 */
63
64
	public function testAuth(int $userId = null, array $expectArray = []) : void
65
	{
66
		/* setup */
67
68
		$auth = new Auth($this->_request);
69
		$auth->login($userId);
70
		new Bootstrap\Auth($this->_registry, $this->_request);
71
72
		/* actual */
73
74
		$actualArray =
75
		[
76
			'myId' => $this->_registry->get('myId'),
77
			'myName' => $this->_registry->get('myName'),
78
			'myUser' => $this->_registry->get('myUser'),
79
			'myEmail' => $this->_registry->get('myEmail'),
80
			'myLanguage' => $this->_registry->get('myLanguage'),
81
			'myGroups' => $this->_registry->get('myGroups'),
82
			'categoriesNew' => $this->_registry->get('categoriesNew'),
83
			'categoriesEdit' => $this->_registry->get('categoriesEdit'),
84
			'categoriesDelete' => $this->_registry->get('categoriesDelete'),
85
			'articlesNew' => $this->_registry->get('articlesNew'),
86
			'articlesEdit' => $this->_registry->get('articlesEdit'),
87
			'articlesDelete' => $this->_registry->get('articlesDelete'),
88
			'extrasNew' => $this->_registry->get('extrasNew'),
89
			'extrasEdit' => $this->_registry->get('extrasEdit'),
90
			'extrasDelete' => $this->_registry->get('extrasDelete'),
91
			'commentsNew' => $this->_registry->get('commentsNew'),
92
			'commentsEdit' => $this->_registry->get('commentsEdit'),
93
			'commentsDelete' => $this->_registry->get('commentsDelete'),
94
			'groupsNew' => $this->_registry->get('groupsNew'),
95
			'groupsEdit' => $this->_registry->get('groupsEdit'),
96
			'groupsDelete' => $this->_registry->get('groupsDelete'),
97
			'usersNew' => $this->_registry->get('usersNew'),
98
			'usersEdit' => $this->_registry->get('usersEdit'),
99
			'usersDelete' => $this->_registry->get('usersDelete'),
100
			'modulesInstall' => $this->_registry->get('modulesInstall'),
101
			'modulesEdit' => $this->_registry->get('modulesEdit'),
102
			'modulesUninstall' => $this->_registry->get('modulesUninstall'),
103
			'settingsEdit' => $this->_registry->get('settingsEdit'),
104
			'filter' => $this->_registry->get('filter'),
105
			'tableNew' => $this->_registry->get('tableNew'),
106
			'tableInstall' => $this->_registry->get('tableInstall'),
107
			'tableEdit' => $this->_registry->get('tableEdit'),
108
			'tableDelete' => $this->_registry->get('tableDelete'),
109
			'tableUninstall' => $this->_registry->get('tableUninstall')
110
		];
111
112
		/* compare */
113
114
		$this->assertEquals($expectArray, $actualArray);
115
	}
116
}
117