|
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
|
|
|
* @requires OS Linux |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
class ResetTest extends TestCaseAbstract |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* setUp |
|
28
|
|
|
* |
|
29
|
|
|
* @since 3.1.0 |
|
30
|
|
|
*/ |
|
31
|
|
|
|
|
32
|
|
|
public function setUp() : void |
|
33
|
|
|
{ |
|
34
|
|
|
parent::setUp(); |
|
35
|
|
|
$optionArray = $this->getOptionArray(); |
|
36
|
|
|
$installer = $this->installerFactory(); |
|
37
|
|
|
$installer->init(); |
|
38
|
|
|
$installer->rawCreate(); |
|
39
|
|
|
$installer->insertSettings($optionArray); |
|
40
|
|
|
$installer->insertUsers($optionArray); |
|
41
|
|
|
Db::forTablePrefix('users') |
|
42
|
|
|
->whereIdIs(1) |
|
43
|
|
|
->findOne() |
|
44
|
|
|
->set('password', 'test') |
|
45
|
|
|
->save(); |
|
46
|
|
|
$setting = $this->settingFactory(); |
|
47
|
|
|
$setting->set('captcha', 1); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* tearDown |
|
52
|
|
|
* |
|
53
|
|
|
* @since 3.1.0 |
|
54
|
|
|
*/ |
|
55
|
|
|
|
|
56
|
|
|
public function tearDown() : void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->dropDatabase(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* testProcess |
|
63
|
|
|
* |
|
64
|
|
|
* @since 3.0.0 |
|
65
|
|
|
* |
|
66
|
|
|
* @param array $postArray |
|
67
|
|
|
* @param string $method |
|
68
|
|
|
* @param string $expect |
|
69
|
|
|
* |
|
70
|
|
|
* @dataProvider providerAutoloader |
|
71
|
|
|
*/ |
|
72
|
|
|
|
|
73
|
|
|
public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void |
|
74
|
|
|
{ |
|
75
|
|
|
/* setup */ |
|
76
|
|
|
|
|
77
|
|
|
$this->_request->set('post', $postArray); |
|
78
|
|
|
if ($method) |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
$resetController = $this |
|
81
|
|
|
->getMockBuilder('Redaxscript\Controller\Reset') |
|
82
|
|
|
->setConstructorArgs( |
|
83
|
|
|
[ |
|
84
|
|
|
$this->_registry, |
|
85
|
|
|
$this->_request, |
|
86
|
|
|
$this->_language, |
|
87
|
|
|
$this->_config |
|
88
|
|
|
]) |
|
89
|
|
|
->setMethods( |
|
90
|
|
|
[ |
|
91
|
|
|
$method |
|
92
|
|
|
]) |
|
93
|
|
|
->getMock(); |
|
94
|
|
|
|
|
95
|
|
|
/* override */ |
|
96
|
|
|
|
|
97
|
|
|
$resetController |
|
98
|
|
|
->expects($this->any()) |
|
99
|
|
|
->method($method); |
|
100
|
|
|
} |
|
101
|
|
|
else |
|
102
|
|
|
{ |
|
103
|
|
|
$resetController = new Controller\Reset($this->_registry, $this->_request, $this->_language, $this->_config); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/* actual */ |
|
107
|
|
|
|
|
108
|
|
|
$actual = $resetController->process(); |
|
109
|
|
|
|
|
110
|
|
|
/* compare */ |
|
111
|
|
|
|
|
112
|
|
|
$this->assertEquals($expect, $actual); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: