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
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Config;
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\Tests\AbstractTestCase;
/**
* @covers \PhpMyAdmin\Config\PageSettings
*/
class PageSettingsTest extends AbstractTestCase
{
/**
* Setup tests
*/
protected function setUp(): void
{
parent::setUp();
parent::setLanguage();
parent::setGlobalConfig();
parent::setTheme();
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = '';
$_SERVER['SCRIPT_NAME'] = 'index.php';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server']['DisableIS'] = false;
}
/**
* Test showGroup when group passed does not exist
*/
public function testShowGroupNonExistent(): void
{
$object = new PageSettings('NonExistent');
$this->assertEquals('', $object->getHTML());
}
/**
* Test showGroup with a known group name
*/
public function testShowGroupBrowse(): void
{
$object = new PageSettings('Browse');
$html = $object->getHTML();
// Test some sample parts
$this->assertStringContainsString(
'<div id="page_settings_modal">'
. '<div class="page_settings">'
. '<form method="post" '
. 'action="index.php?route=%2F&db=db&server=1&lang=en" '
. 'class="config-form disableAjax">',
$html
);
$this->assertStringContainsString('<input type="hidden" name="submit_save" value="Browse">', $html);
$this->assertStringContainsString(
"window.Config.registerFieldValidator('MaxRows', 'validatePositiveNumber', true);\n"
. "window.Config.registerFieldValidator('RepeatCells', 'validateNonNegativeNumber', true);\n"
. "window.Config.registerFieldValidator('LimitChars', 'validatePositiveNumber', true);\n",
$html
);
}
/**
* Test getNaviSettings
*/
public function testGetNaviSettings(): void
{
$pageSettings = new PageSettings('Navi', 'pma_navigation_settings');
$html = $pageSettings->getHTML();
// Test some sample parts
$this->assertStringContainsString('<div id="pma_navigation_settings">', $html);
$this->assertStringContainsString('<input type="hidden" name="submit_save" value="Navi">', $html);
}
}
|