Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / test / libraries / rte / PMA_EVN_getQueryFromRequest_test.php
blob5c6603d4be79302cdb6679eb6b3071dc416ed057
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for generating CREATE EVENT query from HTTP request
6 * @package phpMyAdmin-test
7 */
9 /*
10 * Needed for PMA_backquote()
12 require_once 'libraries/common.lib.php';
15 * Needed by PMA_EVN_getQueryFromRequest()
17 require_once 'libraries/php-gettext/gettext.inc';
20 * Include to test.
22 require_once 'libraries/rte/rte_events.lib.php';
25 class PMA_EVN_getQueryFromRequest_test extends PHPUnit_Framework_TestCase
27 /**
28 * @dataProvider provider
30 public function testgetQueryFromRequest($request, $query, $num_err)
32 global $_REQUEST, $errors;
34 $errors = array();
35 PMA_EVN_setGlobals();
37 unset($_REQUEST);
38 $_REQUEST = $request;
40 $this->assertEquals($query, PMA_EVN_getQueryFromRequest());
41 $this->assertEquals($num_err, count($errors));
44 public function provider()
46 return array(
47 // Testing success
48 array(
49 array( // simple once-off event
50 'item_name' => 's o m e e v e n t\\',
51 'item_type' => 'ONE TIME',
52 'item_execute_at' => '2050-01-01 00:00:00',
53 'item_definition' => 'SET @A=0;'
55 'CREATE EVENT `s o m e e v e n t\` ON SCHEDULE AT \'2050-01-01 00:00:00\' ON COMPLETION NOT PRESERVE DO SET @A=0;',
58 array(
59 array( // full once-off event
60 'item_name' => 'evn',
61 'item_definer' => 'me@home',
62 'item_type' => 'ONE TIME',
63 'item_execute_at' => '2050-01-01 00:00:00',
64 'item_preserve' => 'ON',
65 'item_status' => 'ENABLED',
66 'item_definition' => 'SET @A=0;'
68 'CREATE DEFINER=`me`@`home` EVENT `evn` ON SCHEDULE AT \'2050-01-01 00:00:00\' ON COMPLETION PRESERVE ENABLE DO SET @A=0;',
71 array(
72 array( // simple recurring event
73 'item_name' => 'rec_``evn',
74 'item_type' => 'RECURRING',
75 'item_interval_value' => '365',
76 'item_interval_field' => 'DAY',
77 'item_status' => 'DISABLED',
78 'item_definition' => 'SET @A=0;'
80 'CREATE EVENT `rec_````evn` ON SCHEDULE EVERY 365 DAY ON COMPLETION NOT PRESERVE DISABLE DO SET @A=0;',
83 array(
84 array( // full recurring event
85 'item_name' => 'rec_evn2',
86 'item_definer' => 'evil``user><\\@work\\',
87 'item_type' => 'RECURRING',
88 'item_interval_value' => '365',
89 'item_interval_field' => 'DAY',
90 'item_starts' => '1900-01-01',
91 'item_ends' => '2050-01-01',
92 'item_preserve' => 'ON',
93 'item_status' => 'SLAVESIDE_DISABLED',
94 'item_definition' => 'SET @A=0;'
96 'CREATE DEFINER=`evil````user><\`@`work\` EVENT `rec_evn2` ON SCHEDULE EVERY 365 DAY STARTS \'1900-01-01\' ENDS \'2050-01-01\' ON COMPLETION PRESERVE DISABLE ON SLAVE DO SET @A=0;',
99 // Testing failures
100 array(
101 array( // empty request
103 'CREATE EVENT ON SCHEDULE ON COMPLETION NOT PRESERVE DO ',
106 array(
107 array(
108 'item_name' => 's o m e e v e n t\\',
109 'item_definer' => 'someuser', // invalid definer format
110 'item_type' => 'ONE TIME',
111 'item_execute_at' => '', // no execution time
112 'item_definition' => 'SET @A=0;'
114 'CREATE EVENT `s o m e e v e n t\` ON SCHEDULE ON COMPLETION NOT PRESERVE DO SET @A=0;',
117 array(
118 array(
119 'item_name' => 'rec_``evn',
120 'item_type' => 'RECURRING',
121 'item_interval_value' => '', // no interval value
122 'item_interval_field' => 'DAY',
123 'item_status' => 'DISABLED',
124 'item_definition' => 'SET @A=0;'
126 'CREATE EVENT `rec_````evn` ON SCHEDULE ON COMPLETION NOT PRESERVE DISABLE DO SET @A=0;',
129 array(
130 array( // simple recurring event
131 'item_name' => 'rec_``evn',
132 'item_type' => 'RECURRING',
133 'item_interval_value' => '365',
134 'item_interval_field' => 'CENTURIES', // invalid interval field
135 'item_status' => 'DISABLED',
136 'item_definition' => 'SET @A=0;'
138 'CREATE EVENT `rec_````evn` ON SCHEDULE ON COMPLETION NOT PRESERVE DISABLE DO SET @A=0;',