-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathListDatabaseTest.php
More file actions
70 lines (60 loc) · 2.08 KB
/
Copy pathListDatabaseTest.php
File metadata and controls
70 lines (60 loc) · 2.08 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
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Config;
use PhpMyAdmin\Current;
use PhpMyAdmin\ListDatabase;
use PhpMyAdmin\UserPrivilegesFactory;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
#[CoversClass(ListDatabase::class)]
class ListDatabaseTest extends AbstractTestCase
{
/**
* Test for ListDatabase::exists
*/
public function testExists(): void
{
$dbi = $this->createDatabaseInterface();
$config = new Config();
$config->selectedServer['DisableIS'] = false;
$config->selectedServer['only_db'] = ['single\\_db'];
$object = new ListDatabase($dbi, $config, new UserPrivilegesFactory($dbi));
self::assertTrue($object->exists('single_db'));
}
#[DataProvider('providerForTestGetList')]
public function testGetList(string $currentDbName, string $dbName): void
{
$dbi = $this->createDatabaseInterface();
$config = new Config();
$config->selectedServer['DisableIS'] = false;
$config->selectedServer['only_db'] = ['single\\_db'];
$object = new ListDatabase($dbi, $config, new UserPrivilegesFactory($dbi));
Current::$database = $currentDbName;
self::assertSame(
[['name' => $dbName, 'is_selected' => $currentDbName === $dbName]],
$object->getList(),
);
}
/** @return list<list{string,string}> */
public static function providerForTestGetList(): array
{
return [
['db', 'single_db'],
['single_db', 'single_db'],
];
}
/**
* Test for checkHideDatabase
*/
public function testCheckHideDatabase(): void
{
$dbi = $this->createDatabaseInterface();
$config = new Config();
$config->selectedServer['DisableIS'] = false;
$config->selectedServer['only_db'] = ['single\\_db'];
$config->selectedServer['hide_db'] = 'single\\_db';
$object = new ListDatabase($dbi, $config, new UserPrivilegesFactory($dbi));
self::assertSame([], (array) $object);
}
}