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

tests/unit/Controller/ResetTest.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\Db;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * ResetTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 * @author Balázs Szilágyi
17
 *
18
 * @covers Redaxscript\Controller\ControllerAbstract
19
 * @covers Redaxscript\Controller\Reset
20
 */
21
22
class ResetTest extends TestCaseAbstract
23
{
24
	/**
25
	 * setUp
26
	 *
27
	 * @since 3.1.0
28
	 */
29
30
	public function setUp() : void
31
	{
32
		parent::setUp();
33
		$optionArray = $this->getOptionArray();
34
		$installer = $this->installerFactory();
35
		$installer->init();
36
		$installer->rawCreate();
37
		$installer->insertSettings($optionArray);
38
		$installer->insertUsers($optionArray);
39
		Db::forTablePrefix('users')
40
			->whereIdIs(1)
41
			->findOne()
42
			->set('password', 'test')
43
			->save();
44
		$setting = $this->settingFactory();
45
		$setting->set('captcha', 1);
46
	}
47
48
	/**
49
	 * tearDown
50
	 *
51
	 * @since 3.1.0
52
	 */
53
54
	public function tearDown() : void
55
	{
56
		$this->dropDatabase();
57
	}
58
59
	/**
60
	 * testProcess
61
	 *
62
	 * @since 3.0.0
63
	 *
64
	 * @param array $postArray
65
	 * @param string $method
66
	 * @param string $expect
67
	 *
68
	 * @dataProvider providerAutoloader
69
	 */
70
71
	public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void
72
	{
73
		/* setup */
74
75
		$this->_request->set('post', $postArray);
76
		if ($method)
77
		{
78
			$resetController = $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...
79
				->getMockBuilder('Redaxscript\Controller\Reset')
80
				->setConstructorArgs(
81
				[
82
					$this->_registry,
83
					$this->_request,
84
					$this->_language,
85
					$this->_config
86
				])
87
				->setMethods(
88
				[
89
					$method
90
				])
91
				->getMock();
92
93
			/* override */
94
95
			$resetController
96
				->expects($this->any())
97
				->method($method);
98
		}
99
		else
100
		{
101
			$resetController = new Controller\Reset($this->_registry, $this->_request, $this->_language, $this->_config);
102
		}
103
104
		/* actual */
105
106
		$actual = $resetController->process();
107
108
		/* compare */
109
110
		$this->assertEquals($expect, $actual);
111
	}
112
}
113