phpmyadmin/test/classes/UrlTest.php
Michal Čihař 3b6a994dcd Move collation connection setting to user preferences
It is now handled same way as other user settings.

Issue #11688
Issue #13466

Signed-off-by: Michal Čihař <michal@cihar.com>
2017-11-29 14:16:31 +01:00

109 lines
2.6 KiB
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for methods in URL class
*
* @package PhpMyAdmin-test
*/
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Url;
use PHPUnit\Framework\TestCase;
/**
* Tests for methods in URL class
*
* @package PhpMyAdmin-test
*/
class UrlTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
public function setUp()
{
unset($_COOKIE['pma_lang']);
}
/**
* Test for Url::getCommon for DB only
*
* @return void
*/
public function testDbOnly()
{
$GLOBALS['server'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = 'server=x' . htmlentities($separator) . 'lang=en' ;
$expected = '?db=db'
. htmlentities($separator) . $expected;
$this->assertEquals($expected, Url::getCommon(array('db' => 'db')));
}
/**
* Test for Url::getCommon with new style
*
* @return void
*/
public function testNewStyle()
{
$GLOBALS['server'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = 'server=x' . htmlentities($separator) . 'lang=en' ;
$expected = '?db=db'
. htmlentities($separator) . 'table=table'
. htmlentities($separator) . $expected;
$params = array('db' => 'db', 'table' => 'table');
$this->assertEquals($expected, Url::getCommon($params));
}
/**
* Test for Url::getCommon with alternate divider
*
* @return void
*/
public function testWithAlternateDivider()
{
$GLOBALS['server'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = 'server=x' . $separator . 'lang=en' ;
$expected = '#ABC#db=db' . $separator . 'table=table' . $separator
. $expected;
$this->assertEquals(
$expected,
Url::getCommonRaw(
array('db' => 'db', 'table' => 'table'), '#ABC#'
)
);
}
/**
* Test for Url::getCommon
*
* @return void
*/
public function testDefault()
{
$GLOBALS['server'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = '?server=x' . htmlentities($separator) . 'lang=en' ;
$this->assertEquals($expected, Url::getCommon());
}
}