2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for generating routine execution dialog
6 * @package phpMyAdmin-test
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';
15 require_once 'libraries/rte/rte_routines.lib.php';
17 class PMA_RTN_getExecuteForm_test
extends PHPUnit_Framework_TestCase
19 public function setUp()
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']);
75 * @dataProvider provider_1
77 public function testgetExecuteForm_1($data, $matcher)
79 $GLOBALS['is_ajax_request'] = false;
81 $this->assertTag($matcher, PMA_RTN_getExecuteForm($data), false);
84 public function provider_1()
88 'item_returnlength' => '',
89 'item_returnopts_num' => '',
90 'item_returnopts_text' => '',
91 'item_definition' => 'SELECT 1;',
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' => ''
114 'attributes' => array(
115 'name' => 'item_name'
123 'attributes' => array(
124 'name' => 'funcs[foo]'
132 'attributes' => array(
133 'name' => 'params[foo]',
134 'class' => 'datefield'
142 'attributes' => array(
143 'name' => 'funcs[fob]'
151 'attributes' => array(
152 'name' => 'params[fob]',
153 'class' => 'datetimefield'
161 'attributes' => array(
162 'name' => 'params[fod][]'
170 'attributes' => array(
171 'name' => 'params[foe][]'
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()
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' => ''
227 'attributes' => array(
228 'name' => 'execute_routine'
236 'attributes' => array(
237 'name' => 'ajax_request'