2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * tests for PMA_generate_common_url()
6 * @package phpMyAdmin-test
12 require_once 'PHPUnit/Framework.php';
13 require_once './libraries/core.lib.php';
14 require_once './libraries/url_generating.lib.php';
17 * @package phpMyAdmin-test
19 class PMA_generate_common_url_test
extends PHPUnit_Framework_TestCase
21 public function setUp()
23 unset($_COOKIE['pma_lang'], $_COOKIE['pma_collation_connection']);
26 public function testOldStyle()
28 $GLOBALS['server'] = 'x';
29 $GLOBALS['lang'] = 'x';
30 $GLOBALS['collation_connection'] = 'x';
31 $_SESSION[' PMA_token '] = 'x';
32 $GLOBALS['cfg']['ServerDefault'] = 'y';
34 $separator = PMA_get_arg_separator();
35 $expected = 'server=x' . htmlentities($separator)
36 . 'lang=x' . htmlentities($separator)
37 . 'collation_connection=x' . htmlentities($separator)
42 . htmlentities($separator) . 'table=table'
43 . htmlentities($separator) . $expected;
45 $this->assertEquals($expected, PMA_generate_common_url('db', 'table'));
48 public function testOldStyleDbOnly()
50 $GLOBALS['server'] = 'x';
51 $GLOBALS['lang'] = 'x';
52 $GLOBALS['collation_connection'] = 'x';
53 $_SESSION[' PMA_token '] = 'x';
54 $GLOBALS['cfg']['ServerDefault'] = 'y';
56 $separator = PMA_get_arg_separator();
57 $expected = 'server=x' . htmlentities($separator)
58 . 'lang=x' . htmlentities($separator)
59 . 'collation_connection=x' . htmlentities($separator)
64 . htmlentities($separator) . $expected;
66 $this->assertEquals($expected, PMA_generate_common_url('db'));
69 public function testNewStyle()
71 $GLOBALS['server'] = 'x';
72 $GLOBALS['lang'] = 'x';
73 $GLOBALS['collation_connection'] = 'x';
74 $_SESSION[' PMA_token '] = 'x';
75 $GLOBALS['cfg']['ServerDefault'] = 'y';
77 $separator = PMA_get_arg_separator();
78 $expected = 'server=x' . htmlentities($separator)
79 . 'lang=x' . htmlentities($separator)
80 . 'collation_connection=x' . htmlentities($separator)
85 . htmlentities($separator) . 'table=table'
86 . htmlentities($separator) . $expected;
87 $params = array('db' => 'db', 'table' => 'table');
88 $this->assertEquals($expected, PMA_generate_common_url($params));
91 public function testOldStyleWithAlternateSeparator()
93 $GLOBALS['server'] = 'x';
94 $GLOBALS['lang'] = 'x';
95 $GLOBALS['collation_connection'] = 'x';
96 $_SESSION[' PMA_token '] = 'x';
97 $GLOBALS['cfg']['ServerDefault'] = 'y';
99 $separator = PMA_get_arg_separator();
100 $expected = 'server=x' . $separator
101 . 'lang=x' . $separator
102 . 'collation_connection=x' . $separator
106 $expected = 'db=db' . $separator . 'table=table' . $separator . $expected;
107 $this->assertEquals($expected, PMA_generate_common_url('db', 'table', '&'));
110 public function testOldStyleWithAlternateSeparatorDbOnly()
112 $GLOBALS['server'] = 'x';
113 $GLOBALS['lang'] = 'x';
114 $GLOBALS['collation_connection'] = 'x';
115 $_SESSION[' PMA_token '] = 'x';
116 $GLOBALS['cfg']['ServerDefault'] = 'y';
118 $separator = PMA_get_arg_separator();
119 $expected = 'server=x' . $separator
120 . 'lang=x' . $separator
121 . 'collation_connection=x' . $separator
125 $expected = 'db=db' . $separator . $expected;
126 $this->assertEquals($expected, PMA_generate_common_url('db', '', '&'));
129 public function testDefault()
131 $GLOBALS['server'] = 'x';
132 $GLOBALS['lang'] = 'x';
133 $GLOBALS['collation_connection'] = 'x';
134 $_SESSION[' PMA_token '] = 'x';
135 $GLOBALS['cfg']['ServerDefault'] = 'y';
137 $separator = PMA_get_arg_separator();
138 $expected = 'server=x' . htmlentities($separator)
139 . 'lang=x' . htmlentities($separator)
140 . 'collation_connection=x' . htmlentities($separator)
143 $this->assertEquals($expected, PMA_generate_common_url());