-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathListDatabaseTest.php
More file actions
97 lines (84 loc) · 2.06 KB
/
ListDatabaseTest.php
File metadata and controls
97 lines (84 loc) · 2.06 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
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\ListDatabase;
/**
* @covers \PhpMyAdmin\ListDatabase<extended>
*/
class ListDatabaseTest extends AbstractTestCase
{
/**
* ListDatabase instance
*
* @var ListDatabase
*/
private $object;
/**
* SetUp for test cases
*/
protected function setUp(): void
{
parent::setUp();
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['Server']['only_db'] = ['single\\_db'];
$this->object = new ListDatabase();
}
/**
* Test for ListDatabase::getEmpty
*/
public function testEmpty(): void
{
$arr = new ListDatabase();
self::assertSame('', $arr->getEmpty());
}
/**
* Test for ListDatabase::exists
*/
public function testExists(): void
{
$arr = new ListDatabase();
self::assertTrue($arr->exists('single_db'));
}
public function testGetList(): void
{
$arr = new ListDatabase();
$GLOBALS['db'] = 'db';
self::assertSame([
[
'name' => 'single_db',
'is_selected' => false,
],
], $arr->getList());
$GLOBALS['db'] = 'single_db';
self::assertSame([
[
'name' => 'single_db',
'is_selected' => true,
],
], $arr->getList());
}
/**
* Test for checkHideDatabase
*/
public function testCheckHideDatabase(): void
{
$GLOBALS['cfg']['Server']['hide_db'] = 'single\\_db';
self::assertEquals($this->callFunction(
$this->object,
ListDatabase::class,
'checkHideDatabase',
[]
), '');
}
/**
* Test for getDefault
*/
public function testGetDefault(): void
{
$GLOBALS['db'] = '';
self::assertSame($this->object->getDefault(), '');
$GLOBALS['db'] = 'mysql';
self::assertSame($this->object->getDefault(), 'mysql');
}
}