Completed
Push — master ( 1da492...320203 )
by Henry
07:00
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
21
class RegisterTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 3.1.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$optionArray = $this->getOptionArray();
33
		$installer = $this->installerFactory();
34
		$installer->init();
35
		$installer->rawCreate();
36
		$installer->insertSettings($optionArray);
37
		$installer->insertUsers($optionArray);
38
		$setting = $this->settingFactory();
39
		$setting->set('captcha', 1);
40
		$setting->set('notification', 1);
41
	}
42
43
	/**
44
	 * tearDown
45
	 *
46
	 * @since 3.1.0
47
	 */
48
49
	public function tearDown() : void
50
	{
51
		$this->dropDatabase();
52
	}
53
54
	/**
55
	 * testProcess
56
	 *
57
	 * @since 3.0.0
58
	 *
59
	 * @param array $postArray
60
	 * @param string $method
61
	 * @param string $expect
62
	 *
63
	 * @dataProvider providerAutoloader
64
	 */
65
66
	public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void
67
	{
68
		/* setup */
69
70
		$this->_request->set('post', $postArray);
71
		if ($method)
72
		{
73
			$registerController = $this
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/pull/3687

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

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