Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_RTN_getDataFromRequest_test.php « rte « libraries « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0512cb955daecc3f3ed2a4012c174718d89ed8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Test for fetching routine data from HTTP request
 *
 * @package PhpMyAdmin-test
 */

require_once 'libraries/Util.class.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once './libraries/Types.class.php';

/*
 * Include to test.
 */
require_once 'libraries/rte/rte_routines.lib.php';

/**
 * Test for fetching routine data from HTTP request
 *
 * @package PhpMyAdmin-test
 */
class PMA_RTN_GetDataFromRequest_Test extends PHPUnit_Framework_TestCase
{
    /**
     * Set up
     *
     * @return void
     */
    public function setUp()
    {
        global $cfg;

        $cfg['ShowFunctionFields'] = false;

        $GLOBALS['PMA_Types'] = new PMA_Types_MySQL();
    }

    /**
     * Test for PMA_RTN_getDataFromRequest
     *
     * @param array $in  Input
     * @param array $out Expected output
     *
     * @return void
     *
     * @dataProvider provider
     */
    public function testgetDataFromRequest($in, $out)
    {
        global $_REQUEST;

        unset($_REQUEST);
        foreach ($in as $key => $value) {
            if ($value !== '') {
                $_REQUEST[$key] = $value;
            }
        }
        PMA_RTN_setGlobals();
        $this->assertEquals($out, PMA_RTN_getDataFromRequest());
    }

    /**
     * Data provider for testgetDataFromRequest
     *
     * @return array
     */
    public function provider()
    {
        return array(
            array(
                array(
                    'item_name'                 => '',
                    'item_original_name'        => '',
                    'item_returnlength'         => '',
                    'item_returnopts_num'       => '',
                    'item_returnopts_text'      => '',
                    'item_definition'           => '',
                    'item_comment'              => '',
                    'item_definer'              => '',
                    'item_type'                 => '',
                    'item_type_toggle'          => '',
                    'item_original_type'        => '',
                    'item_param_dir'            => '',
                    'item_param_name'           => '',
                    'item_param_type'           => '',
                    'item_param_length'         => '',
                    'item_param_opts_num'       => '',
                    'item_param_opts_text'      => '',
                    'item_returntype'           => '',
                    'item_isdeterministic'      => '',
                    'item_securitytype'         => '',
                    'item_sqldataaccess'        => ''
                ),
                array(
                    'item_name'                 => '',
                    'item_original_name'        => '',
                    'item_returnlength'         => '',
                    'item_returnopts_num'       => '',
                    'item_returnopts_text'      => '',
                    'item_definition'           => '',
                    'item_comment'              => '',
                    'item_definer'              => '',
                    'item_type'                 => 'PROCEDURE',
                    'item_type_toggle'          => 'FUNCTION',
                    'item_original_type'        => 'PROCEDURE',
                    'item_num_params'           => 0,
                    'item_param_dir'            => array(),
                    'item_param_name'           => array(),
                    'item_param_type'           => array(),
                    'item_param_length'         => array(),
                    'item_param_opts_num'       => array(),
                    'item_param_opts_text'      => array(),
                    'item_returntype'           => '',
                    'item_isdeterministic'      => '',
                    'item_securitytype_definer' => '',
                    'item_securitytype_invoker' => '',
                    'item_sqldataaccess'        => ''
                )
            ),
            array(
                array(
                    'item_name'                 => 'proc2',
                    'item_original_name'        => 'proc',
                    'item_returnlength'         => '',
                    'item_returnopts_num'       => '',
                    'item_returnopts_text'      => '',
                    'item_definition'           => 'SELECT NULL',
                    'item_comment'              => 'some text',
                    'item_definer'              => 'root@localhost',
                    'item_type'                 => 'PROCEDURE',
                    'item_type_toggle'          => 'FUNCTION',
                    'item_original_type'        => 'PROCEDURE',
                    'item_param_dir'            => array(0 => 'IN', 1 => 'FAIL'),
                    'item_param_name'           => array(0 => 'bar', 1 => 'baz'),
                    'item_param_type'           => array(0 => 'INT', 1 => 'FAIL'),
                    'item_param_length'         => array(0 => '20', 1 => ''),
                    'item_param_opts_num'       => array(0 => 'UNSIGNED', 1 => ''),
                    'item_param_opts_text'      => array(0 => '', 1 => 'latin1'),
                    'item_returntype'           => '',
                    'item_isdeterministic'      => 'ON',
                    'item_securitytype'         => 'INVOKER',
                    'item_sqldataaccess'        => 'NO SQL'
                ),
                array(
                    'item_name'                 => 'proc2',
                    'item_original_name'        => 'proc',
                    'item_returnlength'         => '',
                    'item_returnopts_num'       => '',
                    'item_returnopts_text'      => '',
                    'item_definition'           => 'SELECT NULL',
                    'item_comment'              => 'some text',
                    'item_definer'              => 'root@localhost',
                    'item_type'                 => 'PROCEDURE',
                    'item_type_toggle'          => 'FUNCTION',
                    'item_original_type'        => 'PROCEDURE',
                    'item_num_params'           => 2,
                    'item_param_dir'            => array(0 => 'IN', 1 => ''),
                    'item_param_name'           => array(0 => 'bar', 1 => 'baz'),
                    'item_param_type'           => array(0 => 'INT', 1 => ''),
                    'item_param_length'         => array(0 => '20', 1 => ''),
                    'item_param_opts_num'       => array(0 => 'UNSIGNED', 1 => ''),
                    'item_param_opts_text'      => array(0 => '', 1 => 'latin1'),
                    'item_returntype'           => '',
                    'item_isdeterministic'      => ' checked=\'checked\'',
                    'item_securitytype_definer' => '',
                    'item_securitytype_invoker' => ' selected=\'selected\'',
                    'item_sqldataaccess'        => 'NO SQL'
                )
            ),
            array(
                array(
                    'item_name'                 => 'func2',
                    'item_original_name'        => 'func',
                    'item_returnlength'         => '20',
                    'item_returnopts_num'       => '',
                    'item_returnopts_text'      => 'CHARSET utf8',
                    'item_definition'           => 'SELECT NULL',
                    'item_comment'              => 'some text',
                    'item_definer'              => 'root@localhost',
                    'item_type'                 => 'FUNCTION',
                    'item_type_toggle'          => 'PROCEDURE',
                    'item_original_type'        => 'FUNCTION',
                    'item_param_dir'            => array(0 => '', 1 => ''),
                    'item_param_name'           => array(0 => 'bar', 1 => 'baz'),
                    'item_param_type'           => array(
                        0 => '<s>XSS</s>',
                        1 => 'TEXT'
                    ),
                    'item_param_length'         => array(0 => '10,10', 1 => ''),
                    'item_param_opts_num'       => array(0 => 'UNSIGNED', 1 => ''),
                    'item_param_opts_text'      => array(0 => '', 1 => 'utf8'),
                    'item_returntype'           => 'VARCHAR',
                    'item_isdeterministic'      => '',
                    'item_securitytype'         => 'DEFINER',
                    'item_sqldataaccess'        => ''
                ),
                array(
                    'item_name'                 => 'func2',
                    'item_original_name'        => 'func',
                    'item_returnlength'         => '20',
                    'item_returnopts_num'       => '',
                    'item_returnopts_text'      => 'CHARSET utf8',
                    'item_definition'           => 'SELECT NULL',
                    'item_comment'              => 'some text',
                    'item_definer'              => 'root@localhost',
                    'item_type'                 => 'FUNCTION',
                    'item_type_toggle'          => 'PROCEDURE',
                    'item_original_type'        => 'FUNCTION',
                    'item_num_params'           => '2',
                    'item_param_dir'            => array(),
                    'item_param_name'           => array(0 => 'bar', 1 => 'baz'),
                    'item_param_type'           => array(0 => '', 1 => 'TEXT'),
                    'item_param_length'         => array(0 => '10,10', 1 => ''),
                    'item_param_opts_num'       => array(0 => 'UNSIGNED', 1 => ''),
                    'item_param_opts_text'      => array(0 => '', 1 => 'utf8'),
                    'item_returntype'           => 'VARCHAR',
                    'item_isdeterministic'      => '',
                    'item_securitytype_definer' => ' selected=\'selected\'',
                    'item_securitytype_invoker' => '',
                    'item_sqldataaccess'        => ''
                )
            ),
        );
    }
}
?>