2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for PMA_getDbLink_test from common.lib.php
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_getDbLink_test.php
8 * @group common.lib-tests
14 require_once 'libraries/core.lib.php';
15 require_once 'libraries/common.lib.php';
16 require_once 'libraries/url_generating.lib.php';
17 require_once 'libraries/php-gettext/gettext.inc';
19 class PMA_getDbLink_test
extends PHPUnit_Framework_TestCase
24 require_once 'libraries/vendor_config.php';
25 require 'libraries/config.default.php';
26 $_SESSION[' PMA_token '] = 'token';
27 $GLOBALS['lang'] = 'en';
28 $GLOBALS['server'] = 99;
31 function testGetDbLinkEmpty()
33 $GLOBALS['db'] = null;
34 $this->assertEmpty(PMA_getDbLink());
37 function testGetDbLinkNull()
40 $GLOBALS['db'] = 'test_db';
41 $database = $GLOBALS['db'];
42 $this->assertEquals('<a href="' . $cfg['DefaultTabDatabase'] . '?db=' . $database
43 . '&server=99&lang=en&token=token" title="Jump to database "' . htmlspecialchars($database) . '".">'
44 . htmlspecialchars($database) . '</a>',PMA_getDbLink());
47 function testGetDbLink()
50 $database = 'test_database';
51 $this->assertEquals('<a href="' . $cfg['DefaultTabDatabase'] . '?db=' . $database
52 . '&server=99&lang=en&token=token" title="Jump to database "' . htmlspecialchars($database) . '".">'
53 . htmlspecialchars($database) . '</a>',PMA_getDbLink($database));
56 function testGetDbLinkWithSpecialChars()
59 $database = 'test&data\'base';
60 $this->assertEquals('<a href="' . $cfg['DefaultTabDatabase'] . '?db=' . htmlspecialchars(urlencode($database))
61 . '&server=99&lang=en&token=token" title="Jump to database "' . htmlspecialchars($database) . '".">'
62 . htmlspecialchars($database) . '</a>',PMA_getDbLink($database));