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 = |
||
34 | [ |
||
35 | 'adminName' => 'Test', |
||
36 | 'adminUser' => 'test', |
||
37 | 'adminPassword' => 'test', |
||
38 | 'adminEmail' => '[email protected]' |
||
39 | ]; |
||
40 | $installer = $this->installerFactory(); |
||
41 | $installer->init(); |
||
42 | $installer->rawCreate(); |
||
43 | $installer->insertSettings($optionArray); |
||
44 | $installer->insertUsers($optionArray); |
||
45 | Db::forTablePrefix('users') |
||
46 | ->whereIdIs(1) |
||
47 | ->findOne() |
||
48 | ->set('password', 'test') |
||
49 | ->save(); |
||
50 | $setting = $this->settingFactory(); |
||
51 | $setting->set('captcha', 1); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * tearDown |
||
56 | * |
||
57 | * @since 3.1.0 |
||
58 | */ |
||
59 | |||
60 | public function tearDown() : void |
||
61 | { |
||
62 | $this->dropDatabase(); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * testProcess |
||
67 | * |
||
68 | * @since 3.0.0 |
||
69 | * |
||
70 | * @param array $postArray |
||
71 | * @param string $method |
||
72 | * @param string $expect |
||
73 | * |
||
74 | * @dataProvider providerAutoloader |
||
75 | */ |
||
76 | |||
77 | public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void |
||
78 | { |
||
79 | /* setup */ |
||
80 | |||
81 | $this->_request->set('post', $postArray); |
||
82 | if ($method) |
||
0 ignored issues
–
show
|
|||
83 | { |
||
84 | $resetController = $this |
||
85 | ->getMockBuilder('Redaxscript\Controller\Reset') |
||
86 | ->setConstructorArgs( |
||
87 | [ |
||
88 | $this->_registry, |
||
89 | $this->_request, |
||
90 | $this->_language, |
||
91 | $this->_config |
||
92 | ]) |
||
93 | ->setMethods( |
||
94 | [ |
||
95 | $method |
||
96 | ]) |
||
97 | ->getMock(); |
||
98 | |||
99 | /* override */ |
||
100 | |||
101 | $resetController |
||
102 | ->expects($this->any()) |
||
103 | ->method($method); |
||
104 | } |
||
105 | else |
||
106 | { |
||
107 | $resetController = new Controller\Reset($this->_registry, $this->_request, $this->_language, $this->_config); |
||
108 | } |
||
109 | |||
110 | /* actual */ |
||
111 | |||
112 | $actual = $resetController->process(); |
||
113 | |||
114 | /* compare */ |
||
115 | |||
116 | $this->assertEquals($expect, $actual); |
||
117 | } |
||
118 | } |
||
119 |
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: