unit testing: missing required library
[phpmyadmin/crack.git] / test / PMA_generateCommonUrl_test.php
blob3365506a64d4e60ccbf6476df9b3d829c9759c75
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * tests for PMA_generate_common_url()
6 * @version $Id: PMA_get_real_size_test.php 10146 2007-03-20 14:16:18Z cybot_tm $
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' . htmlentities($separator)
106 . 'lang=x' . htmlentities($separator)
107 . 'convcharset=x' . htmlentities($separator)
108 . 'collation_connection=x' . htmlentities($separator)
109 . 'token=x'
112 $expected = 'db=db'
113 . htmlentities($separator) . 'table=table'
114 . htmlentities($separator) . $expected;
115 $this->assertEquals($expected, PMA_generate_common_url('db', 'table', '&'));
118 public function testOldStyleWithAlternateSeparatorDbOnly()
120 $GLOBALS['server'] = 'x';
121 $GLOBALS['lang'] = 'x';
122 $GLOBALS['convcharset'] = 'x';
123 $GLOBALS['collation_connection'] = 'x';
124 $_SESSION[' PMA_token '] = 'x';
125 $GLOBALS['cfg']['ServerDefault'] = 'y';
127 $separator = PMA_get_arg_separator();
128 $expected = 'server=x' . htmlentities($separator)
129 . 'lang=x' . htmlentities($separator)
130 . 'convcharset=x' . htmlentities($separator)
131 . 'collation_connection=x' . htmlentities($separator)
132 . 'token=x'
135 $expected = 'db=db'
136 . htmlentities($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());