2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for generating event editor
6 * @package phpMyAdmin-test
8 require_once 'libraries/php-gettext/gettext.inc';
9 require_once 'libraries/url_generating.lib.php';
10 require_once 'libraries/common.lib.php';
14 require_once 'libraries/rte/rte_events.lib.php';
16 class PMA_EVN_getEditorForm_test
extends PHPUnit_Framework_TestCase
18 public function setUp()
20 if (! function_exists('PMA_DBI_get_tables')) {
21 function PMA_DBI_get_tables($db)
23 return array('table1', 'table`2');
26 $GLOBALS['tear_down']['token'] = false;
27 $GLOBALS['tear_down']['server'] = false;
28 if (! isset($_SESSION[' PMA_token '])) {
29 $_SESSION[' PMA_token '] = '';
30 $GLOBALS['tear_down']['token'] = true;
32 if (! isset($GLOBALS['cfg']['ServerDefault'])) {
33 $GLOBALS['cfg']['ServerDefault'] = '';
34 $GLOBALS['tear_down']['server'] = true;
38 public function tearDown()
40 if ($GLOBALS['tear_down']['token']) {
41 unset($_SESSION[' PMA_token ']);
43 if ($GLOBALS['tear_down']['server']) {
44 unset($GLOBALS['cfg']['ServerDefault']);
46 unset($GLOBALS['tear_down']);
50 * @dataProvider provider_add
52 public function testgetEditorForm_add($data, $matcher)
54 $GLOBALS['is_ajax_request'] = false;
56 $this->assertTag($matcher, PMA_EVN_getEditorForm('add', 'change', $data), '', false);
59 public function provider_add()
63 'item_type' => 'ONE TIME',
64 'item_type_toggle' => 'RECURRING',
65 'item_original_name' => '',
67 'item_execute_at' => '',
68 'item_interval_value' => '',
69 'item_interval_field' => '',
72 'item_definition' => '',
73 'item_preserve' => '',
83 'attributes' => array(
92 'attributes' => array(
101 'attributes' => array(
102 'name' => 'item_status'
110 'attributes' => array(
111 'name' => 'item_type'
119 'attributes' => array(
120 'name' => 'item_changetype'
128 'attributes' => array(
129 'name' => 'item_execute_at'
137 'attributes' => array(
138 'name' => 'item_interval_value'
146 'attributes' => array(
147 'name' => 'item_interval_field'
155 'attributes' => array(
156 'name' => 'item_starts'
164 'attributes' => array(
165 'name' => 'item_ends'
173 'attributes' => array(
174 'name' => 'item_definition'
182 'attributes' => array(
183 'name' => 'item_preserve'
191 'attributes' => array(
192 'name' => 'item_definer'
200 'attributes' => array(
201 'name' => 'item_comment'
209 'attributes' => array(
210 'name' => 'editor_process_add'
218 * @dataProvider provider_edit
220 public function testgetEditorForm_edit($data, $matcher)
222 $GLOBALS['is_ajax_request'] = false;
223 PMA_EVN_setGlobals();
224 $this->assertTag($matcher, PMA_EVN_getEditorForm('edit', 'change', $data), '', false);
227 public function provider_edit()
230 'item_name' => 'foo',
231 'item_type' => 'RECURRING',
232 'item_type_toggle' => 'ONE TIME',
233 'item_original_name' => 'bar',
234 'item_status' => 'ENABLED',
235 'item_execute_at' => '',
236 'item_interval_value' => '1',
237 'item_interval_field' => 'DAY',
240 'item_definition' => 'SET @A=1;',
241 'item_preserve' => '',
242 'item_comment' => '',
251 'attributes' => array(
252 'name' => 'edit_item'
260 'attributes' => array(
261 'name' => 'item_name'
269 'attributes' => array(
270 'name' => 'item_status'
278 'attributes' => array(
279 'name' => 'item_type'
287 'attributes' => array(
288 'name' => 'item_changetype'
296 'attributes' => array(
297 'name' => 'item_execute_at'
305 'attributes' => array(
306 'name' => 'item_interval_value'
314 'attributes' => array(
315 'name' => 'item_interval_field'
323 'attributes' => array(
324 'name' => 'item_starts'
332 'attributes' => array(
333 'name' => 'item_ends'
341 'attributes' => array(
342 'name' => 'item_definition'
350 'attributes' => array(
351 'name' => 'item_preserve'
359 'attributes' => array(
360 'name' => 'item_definer'
368 'attributes' => array(
369 'name' => 'item_comment'
377 'attributes' => array(
378 'name' => 'editor_process_edit'
386 * @dataProvider provider_ajax
388 public function testgetEditorForm_ajax($data, $matcher)
390 $GLOBALS['is_ajax_request'] = true;
391 PMA_EVN_setGlobals();
392 $this->assertTag($matcher, PMA_EVN_getEditorForm('edit', 'change', $data), '', false);
395 public function provider_ajax()
399 'item_type' => 'RECURRING',
400 'item_type_toggle' => 'ONE TIME',
401 'item_original_name' => '',
402 'item_status' => 'ENABLED',
403 'item_execute_at' => '',
404 'item_interval_value' => '',
405 'item_interval_field' => 'DAY',
408 'item_definition' => '',
409 'item_preserve' => '',
410 'item_comment' => '',
419 'attributes' => array(
420 'name' => 'item_type'
428 'attributes' => array(
429 'name' => 'editor_process_edit'
437 'attributes' => array(
438 'name' => 'ajax_request'