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
|
<?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();
$this->assertEquals('', $arr->getEmpty());
}
/**
* Test for ListDatabase::exists
*/
public function testExists(): void
{
$arr = new ListDatabase();
$this->assertTrue($arr->exists('single_db'));
}
public function testGetList(): void
{
$arr = new ListDatabase();
$GLOBALS['db'] = 'db';
$this->assertEquals(
[
[
'name' => 'single_db',
'is_selected' => false,
],
],
$arr->getList()
);
$GLOBALS['db'] = 'single_db';
$this->assertEquals(
[
[
'name' => 'single_db',
'is_selected' => true,
],
],
$arr->getList()
);
}
/**
* Test for checkHideDatabase
*/
public function testCheckHideDatabase(): void
{
$GLOBALS['cfg']['Server']['hide_db'] = 'single\\_db';
$this->assertEquals(
$this->callFunction(
$this->object,
ListDatabase::class,
'checkHideDatabase',
[]
),
''
);
}
/**
* Test for getDefault
*/
public function testGetDefault(): void
{
$GLOBALS['db'] = '';
$this->assertEquals(
$this->object->getDefault(),
''
);
$GLOBALS['db'] = 'mysql';
$this->assertEquals(
$this->object->getDefault(),
'mysql'
);
}
}
|