Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / test / libraries / rte / PMA_RTN_getEditorForm_test.php
blobef96a796f88b93a719a7ac0cf053d5d0fae1d7c7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for generating routine editor
6 * @package phpMyAdmin-test
7 */
8 require_once 'libraries/common.lib.php';
9 require_once 'libraries/data_mysql.inc.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_getEditorForm_test extends PHPUnit_Framework_TestCase
19 public function setUp()
21 if (! function_exists('PMA_generateCharsetDropdownBox')) {
22 function PMA_generateCharsetDropdownBox() {}
24 if (! defined('PMA_CSDROPDOWN_CHARSET')) {
25 define('PMA_CSDROPDOWN_CHARSET', '');
27 if (! function_exists('PMA_DBI_get_tables')) {
28 function PMA_DBI_get_tables($db)
30 return array('table1', 'table`2');
33 $GLOBALS['tear_down']['token'] = false;
34 $GLOBALS['tear_down']['server'] = false;
35 if (! isset($_SESSION[' PMA_token '])) {
36 $_SESSION[' PMA_token '] = '';
37 $GLOBALS['tear_down']['token'] = true;
39 if (! isset($GLOBALS['cfg']['ServerDefault'])) {
40 $GLOBALS['cfg']['ServerDefault'] = '';
41 $GLOBALS['tear_down']['server'] = true;
45 public function tearDown()
47 if ($GLOBALS['tear_down']['token']) {
48 unset($_SESSION[' PMA_token ']);
50 if ($GLOBALS['tear_down']['server']) {
51 unset($GLOBALS['cfg']['ServerDefault']);
53 unset($GLOBALS['tear_down']);
56 public function testgetParameterRow_empty()
58 $GLOBALS['is_ajax_request'] = false;
59 PMA_RTN_setGlobals();
60 $this->assertEquals('', PMA_RTN_getParameterRow(array(), 0));
63 /**
64 * @depends testgetParameterRow_empty
65 * @dataProvider provider_row
67 public function testgetParameterRow($data, $index, $matcher)
69 $GLOBALS['is_ajax_request'] = false;
70 PMA_RTN_setGlobals();
71 $this->assertTag($matcher, PMA_RTN_getParameterRow($data, $index), false);
74 public function provider_row()
76 $data = array(
77 'item_name' => '',
78 'item_original_name' => '',
79 'item_returnlength' => '',
80 'item_returnopts_num' => '',
81 'item_returnopts_text' => '',
82 'item_definition' => '',
83 'item_comment' => '',
84 'item_definer' => '',
85 'item_type' => 'PROCEDURE',
86 'item_type_toggle' => 'FUNCTION',
87 'item_original_type' => 'PROCEDURE',
88 'item_num_params' => 1,
89 'item_param_dir' => array(0 => 'IN'),
90 'item_param_name' => array(0 => 'foo'),
91 'item_param_type' => array(0 => 'INT'),
92 'item_param_length' => array(0 => ''),
93 'item_param_opts_num' => array(0 => 'UNSIGNED'),
94 'item_param_opts_text' => array(0 => ''),
95 'item_returntype' => '',
96 'item_isdeterministic' => '',
97 'item_securitytype_definer' => '',
98 'item_securitytype_invoker' => '',
99 'item_sqldataaccess' => ''
102 return array(
103 array(
104 $data,
106 array(
107 'tag' => 'select',
108 'attributes' => array(
109 'name' => 'item_param_dir[0]'
113 array(
114 $data,
116 array(
117 'tag' => 'input',
118 'attributes' => array(
119 'name' => 'item_param_name[0]'
123 array(
124 $data,
126 array(
127 'tag' => 'select',
128 'attributes' => array(
129 'name' => 'item_param_type[0]'
133 array(
134 $data,
136 array(
137 'tag' => 'input',
138 'attributes' => array(
139 'name' => 'item_param_length[0]'
143 array(
144 $data,
146 array(
147 'tag' => 'select',
148 'attributes' => array(
149 'name' => 'item_param_opts_num[0]'
153 array(
154 $data,
156 array(
157 'tag' => 'a',
158 'attributes' => array(
159 'class' => 'routine_param_remove_anchor'
167 * @depends testgetParameterRow
168 * @dataProvider provider_row_ajax
170 public function testgetParameterRow_ajax($data, $matcher)
172 $GLOBALS['is_ajax_request'] = false;
173 PMA_RTN_setGlobals();
174 $this->assertTag($matcher, PMA_RTN_getParameterRow($data), false);
177 public function provider_row_ajax()
179 $data = array(
180 'item_name' => '',
181 'item_original_name' => '',
182 'item_returnlength' => '',
183 'item_returnopts_num' => '',
184 'item_returnopts_text' => '',
185 'item_definition' => '',
186 'item_comment' => '',
187 'item_definer' => '',
188 'item_type' => 'PROCEDURE',
189 'item_type_toggle' => 'FUNCTION',
190 'item_original_type' => 'PROCEDURE',
191 'item_num_params' => 1,
192 'item_param_dir' => array(0 => 'IN'),
193 'item_param_name' => array(0 => 'foo'),
194 'item_param_type' => array(0 => 'INT'),
195 'item_param_length' => array(0 => ''),
196 'item_param_opts_num' => array(0 => 'UNSIGNED'),
197 'item_param_opts_text' => array(0 => ''),
198 'item_returntype' => '',
199 'item_isdeterministic' => '',
200 'item_securitytype_definer' => '',
201 'item_securitytype_invoker' => '',
202 'item_sqldataaccess' => ''
205 return array(
206 array(
207 $data,
208 array(
209 'tag' => 'select',
210 'attributes' => array(
211 'name' => 'item_param_dir[%s]'
215 array(
216 $data,
217 array(
218 'tag' => 'input',
219 'attributes' => array(
220 'name' => 'item_param_name[%s]'
224 array(
225 $data,
226 array(
227 'tag' => 'select',
228 'attributes' => array(
229 'name' => 'item_param_type[%s]'
233 array(
234 $data,
235 array(
236 'tag' => 'input',
237 'attributes' => array(
238 'name' => 'item_param_length[%s]'
242 array(
243 $data,
244 array(
245 'tag' => 'select',
246 'attributes' => array(
247 'name' => 'item_param_opts_num[%s]'
251 array(
252 $data,
253 array(
254 'tag' => 'a',
255 'attributes' => array(
256 'class' => 'routine_param_remove_anchor'
264 * @depends testgetParameterRow_ajax
265 * @dataProvider provider_editor_1
267 public function testgetEditorForm_1($data, $matcher)
269 $GLOBALS['is_ajax_request'] = false;
270 PMA_RTN_setGlobals();
271 $this->assertTag($matcher, PMA_RTN_getEditorForm('add', '', $data), false);
274 public function provider_editor_1()
276 $data = array(
277 'item_name' => '',
278 'item_original_name' => '',
279 'item_returnlength' => '',
280 'item_returnopts_num' => '',
281 'item_returnopts_text' => '',
282 'item_definition' => '',
283 'item_comment' => '',
284 'item_definer' => '',
285 'item_type' => 'PROCEDURE',
286 'item_type_toggle' => 'FUNCTION',
287 'item_original_type' => 'PROCEDURE',
288 'item_num_params' => 0,
289 'item_param_dir' => array(),
290 'item_param_name' => array(),
291 'item_param_type' => array(),
292 'item_param_length' => array(),
293 'item_param_opts_num' => array(),
294 'item_param_opts_text' => array(),
295 'item_returntype' => '',
296 'item_isdeterministic' => '',
297 'item_securitytype_definer' => '',
298 'item_securitytype_invoker' => '',
299 'item_sqldataaccess' => ''
302 return array(
303 array(
304 $data,
305 array(
306 'tag' => 'input',
307 'attributes' => array(
308 'name' => 'add_item'
312 array(
313 $data,
314 array(
315 'tag' => 'input',
316 'attributes' => array(
317 'name' => 'item_name'
321 array(
322 $data,
323 array(
324 'tag' => 'input',
325 'attributes' => array(
326 'name' => 'item_type'
330 array(
331 $data,
332 array(
333 'tag' => 'input',
334 'attributes' => array(
335 'name' => 'routine_changetype'
341 array(
342 $data,
343 array(
344 'tag' => 'input',
345 'attributes' => array(
346 'name' => 'routine_addparameter'
350 array(
351 $data,
352 array(
353 'tag' => 'input',
354 'attributes' => array(
355 'name' => 'routine_removeparameter'
359 array(
360 $data,
361 array(
362 'tag' => 'select',
363 'attributes' => array(
364 'name' => 'item_returntype'
368 array(
369 $data,
370 array(
371 'tag' => 'input',
372 'attributes' => array(
373 'name' => 'item_returnlength'
377 array(
378 $data,
379 array(
380 'tag' => 'select',
381 'attributes' => array(
382 'name' => 'item_returnopts_num'
386 array(
387 $data,
388 array(
389 'tag' => 'textarea',
390 'attributes' => array(
391 'name' => 'item_definition'
395 array(
396 $data,
397 array(
398 'tag' => 'input',
399 'attributes' => array(
400 'name' => 'item_isdeterministic'
404 array(
405 $data,
406 array(
407 'tag' => 'input',
408 'attributes' => array(
409 'name' => 'item_definer'
413 array(
414 $data,
415 array(
416 'tag' => 'select',
417 'attributes' => array(
418 'name' => 'item_securitytype'
422 array(
423 $data,
424 array(
425 'tag' => 'select',
426 'attributes' => array(
427 'name' => 'item_sqldataaccess'
431 array(
432 $data,
433 array(
434 'tag' => 'input',
435 'attributes' => array(
436 'name' => 'item_comment'
440 array(
441 $data,
442 array(
443 'tag' => 'input',
444 'attributes' => array(
445 'name' => 'editor_process_add'
454 * @depends testgetParameterRow_ajax
455 * @dataProvider provider_editor_2
457 public function testgetEditorForm_2($data, $matcher)
459 $GLOBALS['is_ajax_request'] = false;
460 PMA_RTN_setGlobals();
461 $this->assertTag($matcher, PMA_RTN_getEditorForm('edit', 'change', $data), false);
464 public function provider_editor_2()
466 $data = array(
467 'item_name' => 'foo',
468 'item_original_name' => 'bar',
469 'item_returnlength' => '',
470 'item_returnopts_num' => '',
471 'item_returnopts_text' => '',
472 'item_definition' => 'SELECT 1',
473 'item_comment' => '',
474 'item_definer' => '',
475 'item_type' => 'PROCEDURE',
476 'item_type_toggle' => 'FUNCTION',
477 'item_original_type' => 'PROCEDURE',
478 'item_num_params' => 1,
479 'item_param_dir' => array(0 => 'IN'),
480 'item_param_name' => array(0 => 'baz'),
481 'item_param_type' => array(0 => 'INT'),
482 'item_param_length' => array(0 => '20'),
483 'item_param_opts_num' => array(0 => 'UNSIGNED'),
484 'item_param_opts_text' => array(0 => ''),
485 'item_returntype' => '',
486 'item_isdeterministic' => '',
487 'item_securitytype_definer' => '',
488 'item_securitytype_invoker' => '',
489 'item_sqldataaccess' => 'NO SQL'
492 return array(
493 array(
494 $data,
495 array(
496 'tag' => 'input',
497 'attributes' => array(
498 'name' => 'edit_item'
502 array(
503 $data,
504 array(
505 'tag' => 'input',
506 'attributes' => array(
507 'name' => 'item_name'
511 array(
512 $data,
513 array(
514 'tag' => 'input',
515 'attributes' => array(
516 'name' => 'item_type',
517 'value' => 'FUNCTION'
521 array(
522 $data,
523 array(
524 'tag' => 'input',
525 'attributes' => array(
526 'name' => 'routine_changetype'
532 array(
533 $data,
534 array(
535 'tag' => 'input',
536 'attributes' => array(
537 'name' => 'routine_addparameter'
541 array(
542 $data,
543 array(
544 'tag' => 'input',
545 'attributes' => array(
546 'name' => 'routine_removeparameter'
550 array(
551 $data,
552 array(
553 'tag' => 'select',
554 'attributes' => array(
555 'name' => 'item_returntype'
559 array(
560 $data,
561 array(
562 'tag' => 'input',
563 'attributes' => array(
564 'name' => 'item_returnlength'
568 array(
569 $data,
570 array(
571 'tag' => 'select',
572 'attributes' => array(
573 'name' => 'item_returnopts_num'
577 array(
578 $data,
579 array(
580 'tag' => 'textarea',
581 'attributes' => array(
582 'name' => 'item_definition'
586 array(
587 $data,
588 array(
589 'tag' => 'input',
590 'attributes' => array(
591 'name' => 'item_isdeterministic'
595 array(
596 $data,
597 array(
598 'tag' => 'input',
599 'attributes' => array(
600 'name' => 'item_definer'
604 array(
605 $data,
606 array(
607 'tag' => 'select',
608 'attributes' => array(
609 'name' => 'item_securitytype'
613 array(
614 $data,
615 array(
616 'tag' => 'select',
617 'attributes' => array(
618 'name' => 'item_sqldataaccess'
622 array(
623 $data,
624 array(
625 'tag' => 'input',
626 'attributes' => array(
627 'name' => 'item_comment'
631 array(
632 $data,
633 array(
634 'tag' => 'input',
635 'attributes' => array(
636 'name' => 'editor_process_edit'
645 * @depends testgetParameterRow_ajax
646 * @dataProvider provider_editor_3
648 public function testgetEditorForm_3($data, $matcher)
650 $GLOBALS['is_ajax_request'] = true;
651 PMA_RTN_setGlobals();
652 $this->assertTag($matcher, PMA_RTN_getEditorForm('edit', 'remove', $data), false);
655 public function provider_editor_3()
657 $data = array(
658 'item_name' => 'foo',
659 'item_original_name' => 'bar',
660 'item_returnlength' => '',
661 'item_returnopts_num' => 'UNSIGNED',
662 'item_returnopts_text' => '',
663 'item_definition' => 'SELECT 1',
664 'item_comment' => '',
665 'item_definer' => '',
666 'item_type' => 'FUNCTION',
667 'item_type_toggle' => 'PROCEDURE',
668 'item_original_type' => 'FUNCTION',
669 'item_num_params' => 1,
670 'item_param_dir' => array(0 => ''),
671 'item_param_name' => array(0 => 'baz'),
672 'item_param_type' => array(0 => 'INT'),
673 'item_param_length' => array(0 => '20'),
674 'item_param_opts_num' => array(0 => 'UNSIGNED'),
675 'item_param_opts_text' => array(0 => ''),
676 'item_returntype' => 'INT',
677 'item_isdeterministic' => '',
678 'item_securitytype_definer' => '',
679 'item_securitytype_invoker' => '',
680 'item_sqldataaccess' => 'NO SQL'
683 return array(
684 array(
685 $data,
686 array(
687 'tag' => 'input',
688 'attributes' => array(
689 'name' => 'edit_item'
693 array(
694 $data,
695 array(
696 'tag' => 'input',
697 'attributes' => array(
698 'name' => 'item_name'
702 array(
703 $data,
704 array(
705 'tag' => 'select',
706 'attributes' => array(
707 'name' => 'item_type'
711 array(
712 $data,
713 array(
714 'tag' => 'input',
715 'attributes' => array(
716 'name' => 'routine_addparameter'
720 array(
721 $data,
722 array(
723 'tag' => 'input',
724 'attributes' => array(
725 'name' => 'routine_removeparameter'
729 array(
730 $data,
731 array(
732 'tag' => 'select',
733 'attributes' => array(
734 'name' => 'item_returntype'
738 array(
739 $data,
740 array(
741 'tag' => 'input',
742 'attributes' => array(
743 'name' => 'item_returnlength'
747 array(
748 $data,
749 array(
750 'tag' => 'select',
751 'attributes' => array(
752 'name' => 'item_returnopts_num'
756 array(
757 $data,
758 array(
759 'tag' => 'textarea',
760 'attributes' => array(
761 'name' => 'item_definition'
765 array(
766 $data,
767 array(
768 'tag' => 'input',
769 'attributes' => array(
770 'name' => 'item_isdeterministic'
774 array(
775 $data,
776 array(
777 'tag' => 'input',
778 'attributes' => array(
779 'name' => 'item_definer'
783 array(
784 $data,
785 array(
786 'tag' => 'select',
787 'attributes' => array(
788 'name' => 'item_securitytype'
792 array(
793 $data,
794 array(
795 'tag' => 'select',
796 'attributes' => array(
797 'name' => 'item_sqldataaccess'
801 array(
802 $data,
803 array(
804 'tag' => 'input',
805 'attributes' => array(
806 'name' => 'item_comment'
810 array(
811 $data,
812 array(
813 'tag' => 'input',
814 'attributes' => array(
815 'name' => 'ajax_request'
819 array(
820 $data,
821 array(
822 'tag' => 'input',
823 'attributes' => array(
824 'name' => 'editor_process_edit'
833 * @depends testgetParameterRow_ajax
834 * @dataProvider provider_editor_4
836 public function testgetEditorForm_4($data, $matcher)
838 $GLOBALS['is_ajax_request'] = false;
839 PMA_RTN_setGlobals();
840 $this->assertTag($matcher, PMA_RTN_getEditorForm('edit', 'change', $data), false);
843 public function provider_editor_4()
845 $data = array(
846 'item_name' => 'foo',
847 'item_original_name' => 'bar',
848 'item_returnlength' => '',
849 'item_returnopts_num' => '',
850 'item_returnopts_text' => '',
851 'item_definition' => 'SELECT 1',
852 'item_comment' => '',
853 'item_definer' => '',
854 'item_type' => 'FUNCTION',
855 'item_type_toggle' => 'PROCEDURE',
856 'item_original_type' => 'PROCEDURE',
857 'item_num_params' => 1,
858 'item_param_dir' => array(0 => 'IN'),
859 'item_param_name' => array(0 => 'baz'),
860 'item_param_type' => array(0 => 'INT'),
861 'item_param_length' => array(0 => '20'),
862 'item_param_opts_num' => array(0 => 'UNSIGNED'),
863 'item_param_opts_text' => array(0 => ''),
864 'item_returntype' => '',
865 'item_isdeterministic' => '',
866 'item_securitytype_definer' => '',
867 'item_securitytype_invoker' => '',
868 'item_sqldataaccess' => 'NO SQL'
871 return array(
872 array(
873 $data,
874 array(
875 'tag' => 'input',
876 'attributes' => array(
877 'name' => 'item_type',
878 'value' => 'PROCEDURE'