bug #2967366 Some results of Propose table structure are shown in hex
[phpmyadmin/dkf.git] / test / PMA_generateCommonUrl_test.php
blob2d69574960becdc7169f25065417b18e7922f821
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * tests for PMA_generate_common_url()
6 * @version $Id$
7 * @package phpMyAdmin-test
8 */
10 /**
13 require_once 'PHPUnit/Framework.php';
14 require_once './libraries/core.lib.php';
15 require_once './libraries/url_generating.lib.php';
17 /**
18 * @package phpMyAdmin-test
20 class PMA_generate_common_url_test extends PHPUnit_Framework_TestCase
22 public function setUp()
24 unset($_COOKIE['pma_lang'], $_COOKIE['pma_charset'], $_COOKIE['pma_collation_connection']);
27 public function testOldStyle()
29 $GLOBALS['server'] = 'x';
30 $GLOBALS['lang'] = 'x';
31 $GLOBALS['convcharset'] = 'x';
32 $GLOBALS['collation_connection'] = 'x';
33 $_SESSION[' PMA_token '] = 'x';
34 $GLOBALS['cfg']['ServerDefault'] = 'y';
36 $separator = PMA_get_arg_separator();
37 $expected = 'server=x' . htmlentities($separator)
38 . 'lang=x' . htmlentities($separator)
39 . 'convcharset=x' . htmlentities($separator)
40 . 'collation_connection=x' . htmlentities($separator)
41 . 'token=x'
44 $expected = 'db=db'
45 . htmlentities($separator) . 'table=table'
46 . htmlentities($separator) . $expected;
48 $this->assertEquals($expected, PMA_generate_common_url('db', 'table'));
51 public function testOldStyleDbOnly()
53 $GLOBALS['server'] = 'x';
54 $GLOBALS['lang'] = 'x';
55 $GLOBALS['convcharset'] = 'x';
56 $GLOBALS['collation_connection'] = 'x';
57 $_SESSION[' PMA_token '] = 'x';
58 $GLOBALS['cfg']['ServerDefault'] = 'y';
60 $separator = PMA_get_arg_separator();
61 $expected = 'server=x' . htmlentities($separator)
62 . 'lang=x' . htmlentities($separator)
63 . 'convcharset=x' . htmlentities($separator)
64 . 'collation_connection=x' . htmlentities($separator)
65 . 'token=x'
68 $expected = 'db=db'
69 . htmlentities($separator) . $expected;
71 $this->assertEquals($expected, PMA_generate_common_url('db'));
74 public function testNewStyle()
76 $GLOBALS['server'] = 'x';
77 $GLOBALS['lang'] = 'x';
78 $GLOBALS['convcharset'] = 'x';
79 $GLOBALS['collation_connection'] = 'x';
80 $_SESSION[' PMA_token '] = 'x';
81 $GLOBALS['cfg']['ServerDefault'] = 'y';
83 $separator = PMA_get_arg_separator();
84 $expected = 'server=x' . htmlentities($separator)
85 . 'lang=x' . htmlentities($separator)
86 . 'convcharset=x' . htmlentities($separator)
87 . 'collation_connection=x' . htmlentities($separator)
88 . 'token=x'
91 $expected = '?db=db'
92 . htmlentities($separator) . 'table=table'
93 . htmlentities($separator) . $expected;
94 $params = array('db' => 'db', 'table' => 'table');
95 $this->assertEquals($expected, PMA_generate_common_url($params));
98 public function testOldStyleWithAlternateSeparator()
100 $GLOBALS['server'] = 'x';
101 $GLOBALS['lang'] = 'x';
102 $GLOBALS['convcharset'] = 'x';
103 $GLOBALS['collation_connection'] = 'x';
104 $_SESSION[' PMA_token '] = 'x';
105 $GLOBALS['cfg']['ServerDefault'] = 'y';
107 $separator = PMA_get_arg_separator();
108 $expected = 'server=x' . $separator
109 . 'lang=x' . $separator
110 . 'convcharset=x' . $separator
111 . 'collation_connection=x' . $separator
112 . 'token=x'
115 $expected = 'db=db' . $separator . 'table=table' . $separator . $expected;
116 $this->assertEquals($expected, PMA_generate_common_url('db', 'table', '&'));
119 public function testOldStyleWithAlternateSeparatorDbOnly()
121 $GLOBALS['server'] = 'x';
122 $GLOBALS['lang'] = 'x';
123 $GLOBALS['convcharset'] = 'x';
124 $GLOBALS['collation_connection'] = 'x';
125 $_SESSION[' PMA_token '] = 'x';
126 $GLOBALS['cfg']['ServerDefault'] = 'y';
128 $separator = PMA_get_arg_separator();
129 $expected = 'server=x' . $separator
130 . 'lang=x' . $separator
131 . 'convcharset=x' . $separator
132 . 'collation_connection=x' . $separator
133 . 'token=x'
136 $expected = 'db=db' . $separator . $expected;
137 $this->assertEquals($expected, PMA_generate_common_url('db', '', '&'));
140 public function testDefault()
142 $GLOBALS['server'] = 'x';
143 $GLOBALS['lang'] = 'x';
144 $GLOBALS['convcharset'] = 'x';
145 $GLOBALS['collation_connection'] = 'x';
146 $_SESSION[' PMA_token '] = 'x';
147 $GLOBALS['cfg']['ServerDefault'] = 'y';
149 $separator = PMA_get_arg_separator();
150 $expected = 'server=x' . htmlentities($separator)
151 . 'lang=x' . htmlentities($separator)
152 . 'convcharset=x' . htmlentities($separator)
153 . 'collation_connection=x' . htmlentities($separator)
154 . 'token=x'
156 $this->assertEquals($expected, PMA_generate_common_url());