3.1.3 release
[phpmyadmin/crack.git] / test / PMA_generateCommonUrl_test.php
blob3c6115557ba64c680d6264ab95495bb6bc0a208a
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 class PMA_generate_common_url_test extends PHPUnit_Framework_TestCase
19 public function setUp()
21 unset($_COOKIE['pma_lang'], $_COOKIE['pma_charset'], $_COOKIE['pma_collation_connection']);
24 public function testOldStyle()
26 $GLOBALS['server'] = 'x';
27 $GLOBALS['lang'] = 'x';
28 $GLOBALS['convcharset'] = 'x';
29 $GLOBALS['collation_connection'] = 'x';
30 $_SESSION[' PMA_token '] = 'x';
31 $GLOBALS['cfg']['ServerDefault'] = 'y';
33 $separator = PMA_get_arg_separator();
34 $expected = 'server=x' . htmlentities($separator)
35 . 'lang=x' . htmlentities($separator)
36 . 'convcharset=x' . htmlentities($separator)
37 . 'collation_connection=x' . htmlentities($separator)
38 . 'token=x'
41 $expected = 'db=db'
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['convcharset'] = 'x';
53 $GLOBALS['collation_connection'] = 'x';
54 $_SESSION[' PMA_token '] = 'x';
55 $GLOBALS['cfg']['ServerDefault'] = 'y';
57 $separator = PMA_get_arg_separator();
58 $expected = 'server=x' . htmlentities($separator)
59 . 'lang=x' . htmlentities($separator)
60 . 'convcharset=x' . htmlentities($separator)
61 . 'collation_connection=x' . htmlentities($separator)
62 . 'token=x'
65 $expected = 'db=db'
66 . htmlentities($separator) . $expected;
68 $this->assertEquals($expected, PMA_generate_common_url('db'));
71 public function testNewStyle()
73 $GLOBALS['server'] = 'x';
74 $GLOBALS['lang'] = 'x';
75 $GLOBALS['convcharset'] = 'x';
76 $GLOBALS['collation_connection'] = 'x';
77 $_SESSION[' PMA_token '] = 'x';
78 $GLOBALS['cfg']['ServerDefault'] = 'y';
80 $separator = PMA_get_arg_separator();
81 $expected = 'server=x' . htmlentities($separator)
82 . 'lang=x' . htmlentities($separator)
83 . 'convcharset=x' . htmlentities($separator)
84 . 'collation_connection=x' . htmlentities($separator)
85 . 'token=x'
88 $expected = '?db=db'
89 . htmlentities($separator) . 'table=table'
90 . htmlentities($separator) . $expected;
91 $params = array('db' => 'db', 'table' => 'table');
92 $this->assertEquals($expected, PMA_generate_common_url($params));
95 public function testOldStyleWithAlternateSeparator()
97 $GLOBALS['server'] = 'x';
98 $GLOBALS['lang'] = 'x';
99 $GLOBALS['convcharset'] = 'x';
100 $GLOBALS['collation_connection'] = 'x';
101 $_SESSION[' PMA_token '] = 'x';
102 $GLOBALS['cfg']['ServerDefault'] = 'y';
104 $separator = PMA_get_arg_separator();
105 $expected = 'server=x' . $separator
106 . 'lang=x' . $separator
107 . 'convcharset=x' . $separator
108 . 'collation_connection=x' . $separator
109 . 'token=x'
112 $expected = 'db=db' . $separator . 'table=table' . $separator . $expected;
113 $this->assertEquals($expected, PMA_generate_common_url('db', 'table', '&'));
116 public function testOldStyleWithAlternateSeparatorDbOnly()
118 $GLOBALS['server'] = 'x';
119 $GLOBALS['lang'] = 'x';
120 $GLOBALS['convcharset'] = 'x';
121 $GLOBALS['collation_connection'] = 'x';
122 $_SESSION[' PMA_token '] = 'x';
123 $GLOBALS['cfg']['ServerDefault'] = 'y';
125 $separator = PMA_get_arg_separator();
126 $expected = 'server=x' . $separator
127 . 'lang=x' . $separator
128 . 'convcharset=x' . $separator
129 . 'collation_connection=x' . $separator
130 . 'token=x'
133 $expected = 'db=db' . $separator . $expected;
134 $this->assertEquals($expected, PMA_generate_common_url('db', '', '&'));
137 public function testDefault()
139 $GLOBALS['server'] = 'x';
140 $GLOBALS['lang'] = 'x';
141 $GLOBALS['convcharset'] = 'x';
142 $GLOBALS['collation_connection'] = 'x';
143 $_SESSION[' PMA_token '] = 'x';
144 $GLOBALS['cfg']['ServerDefault'] = 'y';
146 $separator = PMA_get_arg_separator();
147 $expected = 'server=x' . htmlentities($separator)
148 . 'lang=x' . htmlentities($separator)
149 . 'convcharset=x' . htmlentities($separator)
150 . 'collation_connection=x' . htmlentities($separator)
151 . 'token=x'
153 $this->assertEquals($expected, PMA_generate_common_url());