',
Generator::getIcon('b_comment')
);
}
/**
* Test for Util::getIcon
*/
public function testGetIconAlternate(): void
{
$GLOBALS['cfg']['ActionLinksMode'] = 'icons';
$alternate_text = 'alt_str';
$this->assertEquals(
'
',
Generator::getIcon('b_comment', $alternate_text)
);
}
/**
* Test for Util::getIcon
*/
public function testGetIconWithForceText(): void
{
$GLOBALS['cfg']['ActionLinksMode'] = 'icons';
$alternate_text = 'alt_str';
// Here we are checking for an icon embedded inside a span (i.e not a menu
// bar icon
$this->assertEquals(
'
' . $alternate_text . '',
Generator::getIcon('b_comment', $alternate_text, true, false)
);
}
/**
* Test for showPHPDocumentation
*/
public function testShowPHPDocumentation(): void
{
$GLOBALS['server'] = 99;
$GLOBALS['cfg']['ServerDefault'] = 0;
$target = 'docu';
$lang = _pgettext('PHP documentation language', 'en');
$expected = ''
. '
';
$this->assertEquals(
$expected,
Generator::showPHPDocumentation($target)
);
}
/**
* Test for Generator::linkOrButton
*
* @param array $params params
* @param int $limit limit
* @param string $match match
*
* @dataProvider linksOrButtons
*/
public function testLinkOrButton(array $params, int $limit, string $match): void
{
parent::setGlobalConfig();
$restore = $GLOBALS['cfg']['LinkLengthLimit'] ?? 1000;
$GLOBALS['cfg']['LinkLengthLimit'] = $limit;
try {
$result = call_user_func_array(
[
Generator::class,
'linkOrButton',
],
$params
);
$this->assertEquals($match, $result);
} finally {
$GLOBALS['cfg']['LinkLengthLimit'] = $restore;
}
}
/**
* Data provider for Generator::linkOrButton test
*
* @return array
*/
public static function linksOrButtons(): array
{
return [
[
[
'index.php',
null,
'text',
],
1000,
'text',
],
[
[
'index.php',
['some' => 'parameter'],
'text',
],
20,
'text',
],
[
[
'index.php',
null,
'text',
[],
'target',
],
1000,
'text',
],
[
[
'https://mariadb.org/explain_analyzer/analyze/?client=phpMyAdmin&raw_explain=%2B---%2B',
null,
'text',
[],
'target',
],
10,
// This is not the behavior we want for the analyser feature, next test will disable the limit
'text',
],
[
[
'https://mariadb.org/explain_analyzer/analyze/?client=phpMyAdmin&raw_explain=%2B---%2B',
null,
'text',
[],
'target',
false,
],
10,
'text',
],
[
[
'url.php?url=http://phpmyadmin.net/',
null,
'text',
[],
'_blank',
],
1000,
'text',
],
[
[
'index.php?route=/server/databases',
['some' => 'parameter'],
'text',
],
20,
'text',
],
[
[
'index.php?route=/server/databases',
null,
'text',
],
20,
'text',
],
[
[
'index.php?route=/server/databases',
['some' => 'parameter'],
'text',
],
100,
'text',
],
[
[
'index.php?route=/server/databases',
null,
'text',
],
100,
'text',
],
[
[
'index.php',
null,
'text',
['title' => '"'],
],
100,
'text',
],
];
}
public function testFormatSql(): void
{
$this->assertEquals(
'' . "\n"
. 'SELECT 1 < 2' . "\n"
. '',
Generator::formatSql('SELECT 1 < 2')
);
$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 6;
$this->assertEquals(
'' . "\n"
. 'SELECT[...]' . "\n"
. '',
Generator::formatSql('SELECT 1 < 2', true)
);
}
/**
* Test for getServerSSL
*/
public function testGetServerSSL(): void
{
global $cfg;
$sslNotUsed = 'SSL is not being used'
. '
';
$sslNotUsedCaution = 'SSL is not being used'
. '
';
$cfg['Server'] = [
'ssl' => false,
'host' => '127.0.0.1',
];
$this->assertEquals(
$sslNotUsed,
Generator::getServerSSL()
);
$cfg['Server'] = [
'ssl' => false,
'host' => 'custom.host',
];
$cfg['MysqlSslWarningSafeHosts'] = ['localhost', '127.0.0.1'];
$this->assertEquals(
$sslNotUsedCaution,
Generator::getServerSSL()
);
$cfg['Server'] = [
'ssl' => false,
'host' => 'custom.host',
];
$cfg['MysqlSslWarningSafeHosts'] = ['localhost', '127.0.0.1', 'custom.host'];
$this->assertEquals(
$sslNotUsed,
Generator::getServerSSL()
);
$cfg['Server'] = [
'ssl' => false,
'ssl_verify' => true,
'host' => 'custom.host',
];
$this->assertEquals(
$sslNotUsed,
Generator::getServerSSL()
);
$cfg['Server'] = [
'ssl' => true,
'ssl_verify' => false,
'host' => 'custom.host',
];
$this->assertEquals(
'SSL is used with disabled verification'
. '
',
Generator::getServerSSL()
);
$cfg['Server'] = [
'ssl' => true,
'ssl_verify' => true,
'host' => 'custom.host',
];
$this->assertEquals(
'SSL is used without certification authority'
. '
',
Generator::getServerSSL()
);
$cfg['Server'] = [
'ssl' => true,
'ssl_verify' => true,
'ssl_ca' => '/etc/ssl/ca.crt',
'host' => 'custom.host',
];
$this->assertEquals(
'SSL is used'
. '
',
Generator::getServerSSL()
);
}
/**
* Test for Generator::getDefaultFunctionForField
*
* @param array $field field settings
* @param bool $insertMode true if insert mode
* @param string $expected expected result
* @psalm-param array
Bookmark message
SELECT 1;
Message one. Message two.
$sql = "EXPLAIN SELECT 1;";