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

tests/unit/Controller/RecoverTest.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
 * RecoverTest
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\Recover
19
 */
20
21
class RecoverTest 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
	}
41
42
	/**
43
	 * tearDown
44
	 *
45
	 * @since 3.1.0
46
	 */
47
48
	public function tearDown() : void
49
	{
50
		$this->dropDatabase();
51
	}
52
53
	/**
54
	 * testProcess
55
	 *
56
	 * @since 3.0.0
57
	 *
58
	 * @param array $postArray
59
	 * @param string $method
60
	 * @param string $expect
61
	 *
62
	 * @dataProvider providerAutoloader
63
	 */
64
65
	public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void
66
	{
67
		/* setup */
68
69
		$this->_request->set('post', $postArray);
70
		if ($method)
71
		{
72
			$recoverController = $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...
73
				->getMockBuilder('Redaxscript\Controller\Recover')
74
				->setConstructorArgs(
75
				[
76
					$this->_registry,
77
					$this->_request,
78
					$this->_language,
79
					$this->_config
80
				])
81
				->setMethods(
82
				[
83
					$method
84
				])
85
				->getMock();
86
87
			/* override */
88
89
			$recoverController
90
				->expects($this->any())
91
				->method($method);
92
		}
93
		else
94
		{
95
			$recoverController = new Controller\Recover($this->_registry, $this->_request, $this->_language, $this->_config);
96
		}
97
98
		/* actual */
99
100
		$actual = $recoverController->process();
101
102
		/* compare */
103
104
		$this->assertEquals($expect, $actual);
105
	}
106
}
107