-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathUserPasswordTest.php
More file actions
86 lines (76 loc) · 2.57 KB
/
UserPasswordTest.php
File metadata and controls
86 lines (76 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationCleanup;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\AuthenticationPluginFactory;
use PhpMyAdmin\Server\Plugins;
use PhpMyAdmin\Server\Privileges;
use PhpMyAdmin\Template;
use PhpMyAdmin\UserPassword;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use function str_repeat;
#[CoversClass(UserPassword::class)]
class UserPasswordTest extends AbstractTestCase
{
private UserPassword $object;
protected function setUp(): void
{
parent::setUp();
$dbi = $this->createDatabaseInterface();
$config = new Config();
$relation = new Relation($dbi);
$serverPrivileges = new Privileges(
new Template($config),
$dbi,
$relation,
new RelationCleanup($dbi, $relation),
new Plugins($dbi),
$config,
);
$this->object = new UserPassword(
$serverPrivileges,
self::createStub(AuthenticationPluginFactory::class),
$dbi,
);
}
#[DataProvider('providerSetChangePasswordMsg')]
public function testSetChangePasswordMsg(
bool $error,
Message $message,
bool $noPassword,
string $password,
string $passwordConfirmation,
): void {
self::assertEquals(
['error' => $error, 'msg' => $message],
$this->object->setChangePasswordMsg(
$password,
$passwordConfirmation,
$noPassword,
),
);
}
/** @return array{0: bool, 1: Message, 2: bool, 3: string, 4: string}[] */
public static function providerSetChangePasswordMsg(): array
{
return [
[false, Message::success('The profile has been updated.'), true, '', ''],
[true, Message::error('The password is empty!'), false, '', ''],
[true, Message::error('The password is empty!'), false, 'a', ''],
[true, Message::error('The password is empty!'), false, '', 'a'],
[true, Message::error('The passwords aren\'t the same!'), false, 'a', 'b'],
[true, Message::error('Password is too long!'), false, str_repeat('a', 257), str_repeat('a', 257)],
[
false,
Message::success('The profile has been updated.'),
false,
str_repeat('a', 256),
str_repeat('a', 256),
],
];
}
}