-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathDescriptionTest.php
More file actions
117 lines (105 loc) · 2.86 KB
/
DescriptionTest.php
File metadata and controls
117 lines (105 loc) · 2.86 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Config;
use PhpMyAdmin\Config\Descriptions;
use PhpMyAdmin\Config\Settings;
use PhpMyAdmin\Tests\AbstractTestCase;
use function array_keys;
use function in_array;
/**
* @covers \PhpMyAdmin\Config\Descriptions
*/
class DescriptionTest extends AbstractTestCase
{
/**
* Setup tests
*/
protected function setUp(): void
{
parent::setUp();
parent::setGlobalConfig();
}
/**
* @param string $item item
* @param string $type type
* @param string $expected expected result
*
* @dataProvider getValues
*/
public function testGet(string $item, string $type, string $expected): void
{
self::assertSame($expected, Descriptions::get($item, $type));
}
/**
* @return array
*/
public static function getValues(): array
{
return [
[
'AllowArbitraryServer',
'name',
'Allow login to any MySQL server',
],
[
'UnknownSetting',
'name',
'UnknownSetting',
],
[
'UnknownSetting',
'desc',
'',
],
];
}
/**
* Assertion for getting description key
*
* @param string $key key
*/
public function assertGet(string $key): void
{
self::assertNotNull(Descriptions::get($key, 'name'));
self::assertNotNull(Descriptions::get($key, 'desc'));
self::assertNotNull(Descriptions::get($key, 'cmt'));
}
/**
* Test getting all names for configurations
*/
public function testAll(): void
{
$nested = [
'Export',
'Import',
'Schema',
'DBG',
'DefaultTransformations',
'SQLQuery',
];
$settings = new Settings([]);
$cfg = $settings->toArray();
foreach ($cfg as $key => $value) {
$this->assertGet($key);
if ($key == 'Servers') {
self::assertIsArray($value);
self::assertIsArray($value[1]);
foreach ($value[1] as $item => $val) {
$this->assertGet($key . '/1/' . $item);
if ($item != 'AllowDeny') {
continue;
}
foreach ($val as $second => $val2) {
self::assertNotNull($val2);
$this->assertGet($key . '/1/' . $item . '/' . $second);
}
}
} elseif (in_array($key, $nested)) {
self::assertIsArray($value);
foreach (array_keys($value) as $item) {
$this->assertGet($key . '/' . $item);
}
}
}
}
}