Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / test / libraries / rte / PMA_RTN_getExecuteForm_test.php
blobeab74b45a24cafb813d91e707085e62f07f70074
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for generating routine execution dialog
6 * @package phpMyAdmin-test
7 */
8 require_once 'libraries/common.lib.php';
9 require_once 'libraries/sqlparser.lib.php';
10 require_once 'libraries/php-gettext/gettext.inc';
11 require_once 'libraries/url_generating.lib.php';
13 * Include to test.
15 require_once 'libraries/rte/rte_routines.lib.php';
17 class PMA_RTN_getExecuteForm_test extends PHPUnit_Framework_TestCase
19 public function setUp()
21 global $cfg;
23 if (! defined('PMA_MYSQL_INT_VERSION')) {
24 define('PMA_MYSQL_INT_VERSION', 51000);
27 if (! function_exists('PMA_generateCharsetDropdownBox')) {
28 function PMA_generateCharsetDropdownBox() {}
30 if (! defined('PMA_CSDROPDOWN_CHARSET')) {
31 define('PMA_CSDROPDOWN_CHARSET', '');
33 if (! function_exists('PMA_DBI_get_tables')) {
34 function PMA_DBI_get_tables($db)
36 return array('table1', 'table`2');
39 $GLOBALS['tear_down']['token'] = false;
40 $GLOBALS['tear_down']['server'] = false;
41 $GLOBALS['tear_down']['default'] = false;
42 if (! isset($_SESSION[' PMA_token '])) {
43 $_SESSION[' PMA_token '] = '';
44 $GLOBALS['tear_down']['token'] = true;
46 if (! isset($GLOBALS['cfg']['ServerDefault'])) {
47 $GLOBALS['cfg']['ServerDefault'] = '';
48 $GLOBALS['tear_down']['server'] = true;
50 $cfg['ShowFunctionFields'] = true;
51 if (! isset($GLOBALS['cfg']['DefaultFunctions'])) {
52 $cfg['DefaultFunctions']['FUNC_NUMBER'] = '';
53 $cfg['DefaultFunctions']['FUNC_DATE'] = '';
54 $GLOBALS['tear_down']['default'] = true;
56 eval(substr(file_get_contents('libraries/data_mysql.inc.php'), 5, -3)); // FIXME
59 public function tearDown()
61 if ($GLOBALS['tear_down']['token']) {
62 unset($_SESSION[' PMA_token ']);
64 if ($GLOBALS['tear_down']['server']) {
65 unset($GLOBALS['cfg']['ServerDefault']);
67 if ($GLOBALS['tear_down']['default']) {
68 unset($GLOBALS['cfg']['DefaultFunctions']);
70 unset($GLOBALS['tear_down']);
74 /**
75 * @dataProvider provider_1
77 public function testgetExecuteForm_1($data, $matcher)
79 $GLOBALS['is_ajax_request'] = false;
80 PMA_RTN_setGlobals();
81 $this->assertTag($matcher, PMA_RTN_getExecuteForm($data), false);
84 public function provider_1()
86 $data = array(
87 'item_name' => 'foo',
88 'item_returnlength' => '',
89 'item_returnopts_num' => '',
90 'item_returnopts_text' => '',
91 'item_definition' => 'SELECT 1;',
92 'item_comment' => '',
93 'item_definer' => '',
94 'item_type' => 'PROCEDURE',
95 'item_num_params' => 6,
96 'item_param_dir' => array(0 => 'IN', 1 => 'OUT', 2 => 'IN', 3 => 'IN', 4 => 'IN', 5 => 'IN'),
97 'item_param_name' => array(0 => 'foo', 1 => 'foa', 2 => 'fob', 3 => 'foc', 4 => 'fod', 5 => 'foe'),
98 'item_param_type' => array(0 => 'DATE', 1 => 'VARCHAR', 2 => 'DATETIME', 3 => 'GEOMETRY', 4 => 'ENUM', 5 => 'SET'),
99 'item_param_length' => array(0 => '', 1 => '22', 2 => '', 3 => '', 4 => "'a','b'", 5 => "'a','b'"),
100 'item_param_opts_num' => array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => ''),
101 'item_param_opts_text' => array(0 => '', 1 => 'utf8', 2 => '', 3 => '', 4 => '', 5 => ''),
102 'item_returntype' => '',
103 'item_isdeterministic' => '',
104 'item_securitytype_definer' => '',
105 'item_securitytype_invoker' => '',
106 'item_sqldataaccess' => ''
109 return array(
110 array(
111 $data,
112 array(
113 'tag' => 'input',
114 'attributes' => array(
115 'name' => 'item_name'
119 array(
120 $data,
121 array(
122 'tag' => 'select',
123 'attributes' => array(
124 'name' => 'funcs[foo]'
128 array(
129 $data,
130 array(
131 'tag' => 'input',
132 'attributes' => array(
133 'name' => 'params[foo]',
134 'class' => 'datefield'
138 array(
139 $data,
140 array(
141 'tag' => 'select',
142 'attributes' => array(
143 'name' => 'funcs[fob]'
147 array(
148 $data,
149 array(
150 'tag' => 'input',
151 'attributes' => array(
152 'name' => 'params[fob]',
153 'class' => 'datetimefield'
157 array(
158 $data,
159 array(
160 'tag' => 'input',
161 'attributes' => array(
162 'name' => 'params[fod][]'
166 array(
167 $data,
168 array(
169 'tag' => 'input',
170 'attributes' => array(
171 'name' => 'params[foe][]'
175 array(
176 $data,
177 array(
178 'tag' => 'input',
179 'attributes' => array(
180 'name' => 'execute_routine'
188 * @dataProvider provider_2
190 public function testgetExecuteForm_2($data, $matcher)
192 $GLOBALS['is_ajax_request'] = true;
193 PMA_RTN_setGlobals();
194 $this->assertTag($matcher, PMA_RTN_getExecuteForm($data), false);
197 public function provider_2()
199 $data = array(
200 'item_name' => 'foo',
201 'item_returnlength' => '',
202 'item_returnopts_num' => '',
203 'item_returnopts_text' => '',
204 'item_definition' => 'SELECT 1;',
205 'item_comment' => '',
206 'item_definer' => '',
207 'item_type' => 'PROCEDURE',
208 'item_num_params' => 6,
209 'item_param_dir' => array(0 => 'IN', 1 => 'OUT', 2 => 'IN', 3 => 'IN', 4 => 'IN', 5 => 'IN'),
210 'item_param_name' => array(0 => 'foo', 1 => 'foa', 2 => 'fob', 3 => 'foc', 4 => 'fod', 5 => 'foe'),
211 'item_param_type' => array(0 => 'DATE', 1 => 'VARCHAR', 2 => 'DATETIME', 3 => 'GEOMETRY', 4 => 'ENUM', 5 => 'SET'),
212 'item_param_length' => array(0 => '', 1 => '22', 2 => '', 3 => '', 4 => "'a','b'", 5 => "'a','b'"),
213 'item_param_opts_num' => array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => ''),
214 'item_param_opts_text' => array(0 => '', 1 => 'utf8', 2 => '', 3 => '', 4 => '', 5 => ''),
215 'item_returntype' => '',
216 'item_isdeterministic' => '',
217 'item_securitytype_definer' => '',
218 'item_securitytype_invoker' => '',
219 'item_sqldataaccess' => ''
222 return array(
223 array(
224 $data,
225 array(
226 'tag' => 'input',
227 'attributes' => array(
228 'name' => 'execute_routine'
232 array(
233 $data,
234 array(
235 'tag' => 'input',
236 'attributes' => array(
237 'name' => 'ajax_request'