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