Translated using Weblate.
[phpmyadmin.git] / test / libraries / PMA_generateCommonUrl_test.php
blob5e8c6048929f326684c12e8481bd734f8d5770e3
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * tests for PMA_generate_common_url()
6 * @package PhpMyAdmin-test
7 */
9 /*
10 * Include to test.
12 require_once 'libraries/core.lib.php';
13 require_once 'libraries/url_generating.lib.php';
15 class PMA_generate_common_url_test extends PHPUnit_Framework_TestCase
17 public function setUp()
19 unset($_COOKIE['pma_lang'], $_COOKIE['pma_collation_connection']);
22 public function testOldStyle()
24 $GLOBALS['server'] = 'x';
25 $GLOBALS['lang'] = 'x';
26 $GLOBALS['collation_connection'] = 'x';
27 $_SESSION[' PMA_token '] = 'x';
28 $GLOBALS['cfg']['ServerDefault'] = 'y';
30 $separator = PMA_get_arg_separator();
31 $expected = 'server=x' . htmlentities($separator)
32 . 'lang=x' . htmlentities($separator)
33 . 'collation_connection=x' . htmlentities($separator)
34 . 'token=x'
37 $expected = 'db=db'
38 . htmlentities($separator) . 'table=table'
39 . htmlentities($separator) . $expected;
41 $this->assertEquals($expected, PMA_generate_common_url('db', 'table'));
44 public function testOldStyleDbOnly()
46 $GLOBALS['server'] = 'x';
47 $GLOBALS['lang'] = 'x';
48 $GLOBALS['collation_connection'] = 'x';
49 $_SESSION[' PMA_token '] = 'x';
50 $GLOBALS['cfg']['ServerDefault'] = 'y';
52 $separator = PMA_get_arg_separator();
53 $expected = 'server=x' . htmlentities($separator)
54 . 'lang=x' . htmlentities($separator)
55 . 'collation_connection=x' . htmlentities($separator)
56 . 'token=x'
59 $expected = 'db=db'
60 . htmlentities($separator) . $expected;
62 $this->assertEquals($expected, PMA_generate_common_url('db'));
65 public function testNewStyle()
67 $GLOBALS['server'] = 'x';
68 $GLOBALS['lang'] = 'x';
69 $GLOBALS['collation_connection'] = 'x';
70 $_SESSION[' PMA_token '] = 'x';
71 $GLOBALS['cfg']['ServerDefault'] = 'y';
73 $separator = PMA_get_arg_separator();
74 $expected = 'server=x' . htmlentities($separator)
75 . 'lang=x' . htmlentities($separator)
76 . 'collation_connection=x' . htmlentities($separator)
77 . 'token=x'
80 $expected = '?db=db'
81 . htmlentities($separator) . 'table=table'
82 . htmlentities($separator) . $expected;
83 $params = array('db' => 'db', 'table' => 'table');
84 $this->assertEquals($expected, PMA_generate_common_url($params));
87 public function testOldStyleWithAlternateSeparator()
89 $GLOBALS['server'] = 'x';
90 $GLOBALS['lang'] = 'x';
91 $GLOBALS['collation_connection'] = 'x';
92 $_SESSION[' PMA_token '] = 'x';
93 $GLOBALS['cfg']['ServerDefault'] = 'y';
95 $separator = PMA_get_arg_separator();
96 $expected = 'server=x' . $separator
97 . 'lang=x' . $separator
98 . 'collation_connection=x' . $separator
99 . 'token=x'
102 $expected = 'db=db' . $separator . 'table=table' . $separator . $expected;
103 $this->assertEquals($expected, PMA_generate_common_url('db', 'table', '&'));
106 public function testOldStyleWithAlternateSeparatorDbOnly()
108 $GLOBALS['server'] = 'x';
109 $GLOBALS['lang'] = 'x';
110 $GLOBALS['collation_connection'] = 'x';
111 $_SESSION[' PMA_token '] = 'x';
112 $GLOBALS['cfg']['ServerDefault'] = 'y';
114 $separator = PMA_get_arg_separator();
115 $expected = 'server=x' . $separator
116 . 'lang=x' . $separator
117 . 'collation_connection=x' . $separator
118 . 'token=x'
121 $expected = 'db=db' . $separator . $expected;
122 $this->assertEquals($expected, PMA_generate_common_url('db', '', '&'));
125 public function testDefault()
127 $GLOBALS['server'] = 'x';
128 $GLOBALS['lang'] = 'x';
129 $GLOBALS['collation_connection'] = 'x';
130 $_SESSION[' PMA_token '] = 'x';
131 $GLOBALS['cfg']['ServerDefault'] = 'y';
133 $separator = PMA_get_arg_separator();
134 $expected = 'server=x' . htmlentities($separator)
135 . 'lang=x' . htmlentities($separator)
136 . 'collation_connection=x' . htmlentities($separator)
137 . 'token=x'
139 $this->assertEquals($expected, PMA_generate_common_url());