Completed
Push — master ( 4eb4a8...a52438 )
by Henry
07:48
created

tests/unit/Controller/RegisterTest.php (1 issue)

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\Controller;
3
4
use Redaxscript\Controller;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * RegisterTest
9
 *
10
 * @since 3.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 * @author Balázs Szilágyi
16
 *
17
 * @covers Redaxscript\Controller\ControllerAbstract
18
 * @covers Redaxscript\Controller\Register
19
 *
20
 * @requires OS Linux
21
 */
22
23
class RegisterTest 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();
35
		$installer = $this->installerFactory();
36
		$installer->init();
37
		$installer->rawCreate();
38
		$installer->insertSettings($optionArray);
39
		$installer->insertUsers($optionArray);
40
		$setting = $this->settingFactory();
41
		$setting->set('captcha', 1);
42
		$setting->set('notification', 1);
43
	}
44
45
	/**
46
	 * tearDown
47
	 *
48
	 * @since 3.1.0
49
	 */
50
51
	public function tearDown() : void
52
	{
53
		$this->dropDatabase();
54
	}
55
56
	/**
57
	 * testProcess
58
	 *
59
	 * @since 3.0.0
60
	 *
61
	 * @param array $postArray
62
	 * @param string $method
63
	 * @param string $expect
64
	 *
65
	 * @dataProvider providerAutoloader
66
	 */
67
68
	public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void
69
	{
70
		/* setup */
71
72
		$this->_request->set('post', $postArray);
73
		if ($method)
0 ignored issues
show
Bug Best Practice introduced by
The expression $method of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
74
		{
75
			$registerController = $this
76
				->getMockBuilder('Redaxscript\Controller\Register')
77
				->setConstructorArgs(
78
				[
79
					$this->_registry,
80
					$this->_request,
81
					$this->_language,
82
					$this->_config
83
				])
84
				->setMethods(
85
				[
86
					$method
87
				])
88
				->getMock();
89
90
			/* override */
91
92
			$registerController
93
				->expects($this->any())
94
				->method($method);
95
		}
96
		else
97
		{
98
			$registerController = new Controller\Register($this->_registry, $this->_request, $this->_language, $this->_config);
99
		}
100
101
		/* actual */
102
103
		$actual = $registerController->process();
104
105
		/* compare */
106
107
		$this->assertEquals($expect, $actual);
108
	}
109
}
110