3 * Tests for displaying results
5 * @package PhpMyAdmin-test
11 use PMA\libraries\plugins\transformations\Text_Plain_Link
;
13 require_once 'libraries/relation.lib.php';
14 require_once 'libraries/string.lib.php';
15 require_once 'test/PMATestCase.php';
18 * Test cases for displaying results.
20 * @package PhpMyAdmin-test
22 class DisplayResultsTest
extends PMATestCase
30 * Sets up the fixture, for example, opens a network connection.
31 * This method is called before a test is executed.
36 protected function setUp()
38 $GLOBALS['server'] = 0;
39 $this->object = new PMA\libraries\
DisplayResults('as', '', '', '');
40 $GLOBALS['PMA_Config'] = new PMA\libraries\
Config();
41 $GLOBALS['PMA_Config']->enableBc();
42 $GLOBALS['text_dir'] = 'ltr';
43 $GLOBALS['collation_connection'] = 'utf-8';
45 $dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
46 ->disableOriginalConstructor()
49 $dbi->expects($this->any())->method('fieldFlags')
50 ->will($this->returnArgument(1));
52 $GLOBALS['dbi'] = $dbi;
56 * Tears down the fixture, for example, closes a network connection.
57 * This method is called after a test is executed.
62 protected function tearDown()
68 * Call private functions by setting visibility to public.
70 * @param string $name method name
71 * @param array $params parameters for the invocation
73 * @return the output from the private method.
75 private function _callPrivateFunction($name, $params)
77 $class = new ReflectionClass('PMA\libraries\DisplayResults');
78 $method = $class->getMethod($name);
79 $method->setAccessible(true);
80 return $method->invokeArgs($this->object, $params);
84 * Test for _isSelect function
88 public function testisSelect()
90 $parser = new \PhpMyAdmin\SqlParser\
Parser('SELECT * FROM pma');
92 $this->_callPrivateFunction(
96 'statement' => $parser->statements
[0],
97 'select_from' => true,
105 * Test for navigation buttons
107 * @param string $caption iconic caption for button
108 * @param string $title text for button
109 * @param integer $pos position for next query
110 * @param string $html_sql_query query ready for display
111 * @param string $output output from the _getTableNavigationButton
116 * @dataProvider providerForTestGetTableNavigationButton
118 public function testGetTableNavigationButton(
119 $caption, $title, $pos, $html_sql_query, $output
121 $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
122 $_SESSION[' PMA_token '] = 'token';
126 $this->_callPrivateFunction(
127 '_getTableNavigationButton',
128 array(&$caption, $title, $pos, $html_sql_query, true)
134 * Provider for testGetTableNavigationButton
136 * @return array array data for testGetTableNavigationButton
138 public function providerForTestGetTableNavigationButton()
145 'SELECT * FROM `pma_bookmark` WHERE 1',
146 '<td><form action="sql.php" method="post" >'
147 . '<input type="hidden" name="db" value="as" />'
148 . '<input type="hidden" name="lang" value="en" />'
149 . '<input type="hidden" name="collation_connection" value="utf-8" />'
150 . '<input type="hidden" name="token" value="token" />'
151 . '<input type="hidden" name="sql_query" value="SELECT * '
152 . 'FROM `pma_bookmark` WHERE 1" />'
153 . '<input type="hidden" name="pos" value="1" />'
154 . '<input type="hidden" name="is_browse_distinct" value="" />'
155 . '<input type="hidden" name="goto" value="" />'
156 . '<input type="submit" name="navig" class="ajax" '
157 . 'value="btn" title="Submit" /></form></td>'
163 * Test for table navigation
167 * @dataProvider providerForTestGetTableNavigation
169 public function testGetTableNavigation(
170 // $pos_next, $pos_prev, $is_innodb, $output
172 $_SESSION['tmpval']['max_rows'] = '20';
173 $_SESSION['tmpval']['pos'] = true;
174 $GLOBALS['num_rows'] = '20';
175 $GLOBALS['unlim_num_rows'] = '50';
176 $GLOBALS['cfg']['ShowAll'] = true;
177 $_SESSION['tmpval']['repeat_cells'] = '1';
180 * FIXME Counting words of a generated large HTML is not a good way
181 * of testing IMO. Introduce more granular assertions that assert for
182 * existence of important content inside the generated HTML.
188 $this->_callPrivateFunction(
189 '_getTableNavigation',
191 $pos_next, $pos_prev, $is_innodb
197 $this->markTestIncomplete('Not yet implemented!');
201 * Provider for testing table navigation
203 * @return array data for testGetTableNavigation
205 public function providerForTestGetTableNavigation()
218 * Data provider for testGetClassesForColumn
220 * @return array parameters and output
222 public function dataProviderForTestGetClassesForColumn()
231 'data grid_edit not_null '
237 * Test for _getClassesForColumn
239 * @param string $grid_edit_class the class for all editable columns
240 * @param string $not_null_class the class for not null columns
241 * @param string $relation_class the class for relations in a column
242 * @param string $hide_class the class for visibility of a column
243 * @param string $field_type_class the class related to type of the field
244 * @param string $output output of__getResettedClassForInlineEdit
248 * @dataProvider dataProviderForTestGetClassesForColumn
250 public function testGetClassesForColumn(
251 $grid_edit_class, $not_null_class, $relation_class,
252 $hide_class, $field_type_class, $output
254 $GLOBALS['cfg']['BrowsePointerEnable'] = true;
255 $GLOBALS['cfg']['BrowseMarkerEnable'] = true;
259 $this->_callPrivateFunction(
260 '_getClassesForColumn',
262 $grid_edit_class, $not_null_class, $relation_class,
263 $hide_class, $field_type_class
270 * Test for _getClassForDateTimeRelatedFields - case 1
274 public function testGetClassForDateTimeRelatedFieldsCase1()
278 $this->_callPrivateFunction(
279 '_getClassForDateTimeRelatedFields',
280 array(PMA\libraries\DisplayResults
::DATETIME_FIELD
)
286 * Test for _getClassForDateTimeRelatedFields - case 2
290 public function testGetClassForDateTimeRelatedFieldsCase2()
294 $this->_callPrivateFunction(
295 '_getClassForDateTimeRelatedFields',
296 array(PMA\libraries\DisplayResults
::DATE_FIELD
)
302 * Test for _getClassForDateTimeRelatedFields - case 3
306 public function testGetClassForDateTimeRelatedFieldsCase3()
310 $this->_callPrivateFunction(
311 '_getClassForDateTimeRelatedFields',
312 array(PMA\libraries\DisplayResults
::STRING_FIELD
)
318 * Test for _getOffsets - case 1
322 public function testGetOffsetsCase1()
324 $_SESSION['tmpval']['max_rows'] = PMA\libraries\DisplayResults
::ALL_ROWS
;
327 $this->_callPrivateFunction('_getOffsets', array())
332 * Test for _getOffsets - case 2
336 public function testGetOffsetsCase2()
338 $_SESSION['tmpval']['max_rows'] = 5;
339 $_SESSION['tmpval']['pos'] = 4;
342 $this->_callPrivateFunction('_getOffsets', array())
347 * Data provider for testGetCheckboxForMultiRowSubmissions
349 * @return array parameters and output
351 public function dataProviderForGetCheckboxForMultiRowSubmissions()
355 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60'
356 . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
357 . 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
358 . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message'
359 . '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_'
371 '%60new%60.%60id%60+%3D+1',
372 array('`new`.`id`' => '= 1'),
373 '[%_PMA_CHECKBOX_DIR_%]',
376 '<td class="klass" class="center print_ignore"><input type'
377 . '="checkbox" id="id_rows_to_delete0[%_PMA_CHECKBOX_DIR_%]" name='
378 . '"rows_to_delete[0]" class="multi_checkbox checkall" value="%60'
379 . 'new%60.%60id%60+%3D+1" /><input type="hidden" class="condition_'
380 . 'array" value="{"`new`.`id`":"= 1"}" /> '
387 * Test for _getCheckboxForMultiRowSubmissions
389 * @param string $del_url delete url
390 * @param array $displayParts array with explicit indexes for all
391 * the display elements
392 * @param string $row_no the row number
393 * @param string $where_clause_html url encoded where clause
394 * @param array $condition_array array of conditions in the where clause
395 * @param string $id_suffix suffix for the id
396 * @param string $class css classes for the td element
397 * @param string $output output of _getCheckboxForMultiRowSubmissions
401 * @dataProvider dataProviderForGetCheckboxForMultiRowSubmissions
403 public function testGetCheckboxForMultiRowSubmissions(
404 $del_url, $displayParts, $row_no, $where_clause_html, $condition_array,
405 $id_suffix, $class, $output
409 $this->_callPrivateFunction(
410 '_getCheckboxForMultiRowSubmissions',
412 $del_url, $displayParts, $row_no, $where_clause_html,
413 $condition_array, $id_suffix, $class
420 * Data provider for testGetEditLink
422 * @return array parameters and output
424 public function dataProviderForGetEditLink()
428 'tbl_change.php?db=Data&table=customer&where_clause=%60'
429 . 'customer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
430 . 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_'
432 'klass edit_row_anchor',
433 '<span class="nowrap"><img src="themes/dot.gif" title="Edit" alt='
434 . '"Edit" class="icon ic_b_edit" /> Edit</span>',
435 '`customer`.`id` = 1',
436 '%60customer%60.%60id%60+%3D+1',
437 '<td class="klass edit_row_anchor center print_ignore" ><span class="nowrap"><input type="hidden" name="subform[1][db]" value="Data" /><input type="hidden" name="subform[1][table]" value="customer" /><input type="hidden" name="subform[1][where_clause]" value="`customer`.`id` = 1" /><input type="hidden" name="subform[1][clause_is_unique]" value="1" /><input type="hidden" name="subform[1][sql_query]" value="SELECT * FROM `customer`" /><input type="hidden" name="subform[1][goto]" value="sql.php" /><input type="hidden" name="subform[1][default_action]" value="update" /><input type="hidden" name="subform[1][redirect]" value="tbl_change.php" /><input type="hidden" name="subform[1][token]" value="token" />
438 <a href="#usesubform[1]=1" class="formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Edit" alt="Edit" class="icon ic_b_edit" /> Edit</span> </a>
439 <input type="hidden" class="where_clause" value ="%60customer%60.%60id%60+%3D+1" /></span></td>'
445 * Test for _getEditLink
447 * @param string $edit_url edit url
448 * @param string $class css classes for td element
449 * @param string $edit_str text for the edit link
450 * @param string $where_clause where clause
451 * @param string $where_clause_html url encoded where clause
452 * @param string $output output of _getEditLink
456 * @dataProvider dataProviderForGetEditLink
458 public function testGetEditLink(
459 $edit_url, $class, $edit_str, $where_clause, $where_clause_html, $output
461 $GLOBALS['cfg']['ActionLinksMode'] = 'both';
462 $GLOBALS['cfg']['LinkLengthLimit'] = 1000;
466 $this->_callPrivateFunction(
469 $edit_url, $class, $edit_str, $where_clause, $where_clause_html
476 * Data provider for testGetCopyLink
478 * @return array parameters and output
480 public function dataProviderForGetCopyLink()
484 'tbl_change.php?db=Data&table=customer&where_clause=%60cust'
485 . 'omer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
486 . 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_'
488 '<span class="nowrap"><img src="themes/dot.gif" title="Copy" alt'
489 . '="Copy" class="icon ic_b_insrow" /> Copy</span>',
490 '`customer`.`id` = 1',
491 '%60customer%60.%60id%60+%3D+1',
493 '<td class="klass center print_ignore" ><span class="nowrap"><input type="hidden" name="subform[1][db]" value="Data" /><input type="hidden" name="subform[1][table]" value="customer" /><input type="hidden" name="subform[1][where_clause]" value="`customer`.`id` = 1" /><input type="hidden" name="subform[1][clause_is_unique]" value="1" /><input type="hidden" name="subform[1][sql_query]" value="SELECT * FROM `customer`" /><input type="hidden" name="subform[1][goto]" value="sql.php" /><input type="hidden" name="subform[1][default_action]" value="insert" /><input type="hidden" name="subform[1][redirect]" value="tbl_change.php" /><input type="hidden" name="subform[1][token]" value="token" />
494 <a href="#usesubform[1]=1" class="formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" class="icon ic_b_insrow" /> Copy</span> </a>
495 <input type="hidden" class="where_clause" value="%60customer%60.%60id%60+%3D+1" /></span></td>'
501 * Test for _getCopyLink
503 * @param string $copy_url copy url
504 * @param string $copy_str text for the copy link
505 * @param string $where_clause where clause
506 * @param string $where_clause_html url encoded where clause
507 * @param string $class css classes for the td element
508 * @param string $output output of _getCopyLink
512 * @dataProvider dataProviderForGetCopyLink
514 public function testGetCopyLink(
515 $copy_url, $copy_str, $where_clause, $where_clause_html, $class, $output
517 $GLOBALS['cfg']['ActionLinksMode'] = 'both';
518 $GLOBALS['cfg']['LinkLengthLimit'] = 1000;
522 $this->_callPrivateFunction(
525 $copy_url, $copy_str, $where_clause, $where_clause_html, $class
532 * Data provider for testGetDeleteLink
534 * @return array parameters and output
536 public function dataProviderForGetDeleteLink()
540 'sql.php?db=Data&table=customer&sql_query=DELETE+FROM+%60'
541 . 'Data%60.%60customer%60+WHERE+%60customer%60.%60id%60+%3D+1&'
542 . 'message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb'
543 . '%3DData%26table%3Dcustomer%26sql_query%3DSELECT%2B%252A%2BFROM'
544 . '%2B%2560customer%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen'
545 . '%2Bdeleted%26goto%3Dtbl_structure.php',
546 '<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
547 . 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
548 'DELETE FROM `Data`.`customer` WHERE `customer`.`id` = 1',
550 '<td class="klass center print_ignore" ><input type="hidden" name="subform[1][db]" value="Data" /><input type="hidden" name="subform[1][table]" value="customer" /><input type="hidden" name="subform[1][sql_query]" value="DELETE FROM `Data`.`customer` WHERE `customer`.`id` = 1" /><input type="hidden" name="subform[1][message_to_show]" value="The row has been deleted" /><input type="hidden" name="subform[1][goto]" value="sql.php?db=Data&table=customer&sql_query=SELECT+%2A+FROM+%60customer%60&message_to_show=The+row+has+been+deleted&goto=tbl_structure.php" /><input type="hidden" name="subform[1][redirect]" value="sql.php" /><input type="hidden" name="subform[1][token]" value="token" />
551 <a href="#usesubform[1]=1" class="delete_row requireConfirm formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span> </a>
552 <div class="hide">DELETE FROM `Data`.`customer` WHERE `customer`.`id` = 1</div></td>'
558 * Test for _getDeleteLink
560 * @param string $del_url delete url
561 * @param string $del_str text for the delete link
562 * @param string $js_conf text for the JS confirmation
563 * @param string $class css classes for the td element
564 * @param string $output output of _getDeleteLink
568 * @dataProvider dataProviderForGetDeleteLink
570 public function testGetDeleteLink(
571 $del_url, $del_str, $js_conf, $class, $output
573 $GLOBALS['cfg']['ActionLinksMode'] = 'both';
574 $GLOBALS['cfg']['LinkLengthLimit'] = 1000;
578 $this->_callPrivateFunction(
581 $del_url, $del_str, $js_conf, $class
588 * Data provider for testGetCheckboxAndLinks
590 * @return array parameters and output
592 public function dataProviderForGetCheckboxAndLinks()
596 PMA\libraries\DisplayResults
::POSITION_LEFT
,
597 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data'
598 . '%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
599 . 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
600 . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26'
601 . 'message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3D'
602 . 'tbl_structure.php',
614 '%60new%60.%60id%60+%3D+1',
616 '`new`.`id`' => '= 1',
618 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
619 . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
620 . 'FROM+%60new%60&goto=sql.php&default_action=update',
621 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
622 . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
623 . 'FROM+%60new%60&goto=sql.php&default_action=insert',
625 '<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
626 . 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
627 '<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
628 . 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
629 '<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
630 . 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
631 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
632 '<td class="center print_ignore"><input type="checkbox" id="id_rows_to_delete0_left" name="rows_to_delete[0]" class="multi_checkbox checkall" value="%60new%60.%60id%60+%3D+1" /><input type="hidden" class="condition_array" value="{"`new`.`id`":"= 1"}" /> </td><td class="edit_row_anchor center print_ignore" ><span class="nowrap"><input type="hidden" name="subform[1][db]" value="data" /><input type="hidden" name="subform[1][table]" value="new" /><input type="hidden" name="subform[1][where_clause]" value="`new`.`id` = 1" /><input type="hidden" name="subform[1][clause_is_unique]" value="1" /><input type="hidden" name="subform[1][sql_query]" value="SELECT * FROM `new`" /><input type="hidden" name="subform[1][goto]" value="sql.php" /><input type="hidden" name="subform[1][default_action]" value="update" /><input type="hidden" name="subform[1][redirect]" value="tbl_change.php" /><input type="hidden" name="subform[1][token]" value="token" />
633 <a href="#usesubform[1]=1" class="formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Edit" alt="Edit" class="icon ic_b_edit" /> Edit</span> </a>
634 <input type="hidden" class="where_clause" value ="%60new%60.%60id%60+%3D+1" /></span></td><td class="center print_ignore" ><span class="nowrap"><input type="hidden" name="subform[2][db]" value="data" /><input type="hidden" name="subform[2][table]" value="new" /><input type="hidden" name="subform[2][where_clause]" value="`new`.`id` = 1" /><input type="hidden" name="subform[2][clause_is_unique]" value="1" /><input type="hidden" name="subform[2][sql_query]" value="SELECT * FROM `new`" /><input type="hidden" name="subform[2][goto]" value="sql.php" /><input type="hidden" name="subform[2][default_action]" value="insert" /><input type="hidden" name="subform[2][redirect]" value="tbl_change.php" /><input type="hidden" name="subform[2][token]" value="token" />
635 <a href="#usesubform[2]=1" class="formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" class="icon ic_b_insrow" /> Copy</span> </a>
636 <input type="hidden" class="where_clause" value="%60new%60.%60id%60+%3D+1" /></span></td><td class="center print_ignore" ><input type="hidden" name="subform[3][db]" value="data" /><input type="hidden" name="subform[3][table]" value="new" /><input type="hidden" name="subform[3][sql_query]" value="DELETE FROM `data`.`new` WHERE `new`.`id` = 1" /><input type="hidden" name="subform[3][message_to_show]" value="The row has been deleted" /><input type="hidden" name="subform[3][goto]" value="sql.php?db=data&table=new&sql_query=SELECT+%2A+FROM+%60new%60&message_to_show=The+row+has+been+deleted&goto=tbl_structure.php" /><input type="hidden" name="subform[3][redirect]" value="sql.php" /><input type="hidden" name="subform[3][token]" value="token" />
637 <a href="#usesubform[3]=1" class="delete_row requireConfirm formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span> </a>
638 <div class="hide">DELETE FROM `data`.`new` WHERE `new`.`id` = 1</div></td>'
642 PMA\libraries\DisplayResults
::POSITION_RIGHT
,
643 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60'
644 . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
645 . 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
646 . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message'
647 . '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_'
660 '%60new%60.%60id%60+%3D+1',
662 '`new`.`id`' => '= 1',
664 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
665 . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
666 . 'FROM+%60new%60&goto=sql.php&default_action=update',
667 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
668 . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
669 . 'FROM+%60new%60&goto=sql.php&default_action=insert',
671 '<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
672 . 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
673 '<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
674 . 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
675 '<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
676 . 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
677 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
678 '<td class="center print_ignore" ><input type="hidden" name="subform[1][db]" value="data" /><input type="hidden" name="subform[1][table]" value="new" /><input type="hidden" name="subform[1][sql_query]" value="DELETE FROM `data`.`new` WHERE `new`.`id` = 1" /><input type="hidden" name="subform[1][message_to_show]" value="The row has been deleted" /><input type="hidden" name="subform[1][goto]" value="sql.php?db=data&table=new&sql_query=SELECT+%2A+FROM+%60new%60&message_to_show=The+row+has+been+deleted&goto=tbl_structure.php" /><input type="hidden" name="subform[1][redirect]" value="sql.php" /><input type="hidden" name="subform[1][token]" value="token" />
679 <a href="#usesubform[1]=1" class="delete_row requireConfirm formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span> </a>
680 <div class="hide">DELETE FROM `data`.`new` WHERE `new`.`id` = 1</div></td><td class="center print_ignore" ><span class="nowrap"><input type="hidden" name="subform[2][db]" value="data" /><input type="hidden" name="subform[2][table]" value="new" /><input type="hidden" name="subform[2][where_clause]" value="`new`.`id` = 1" /><input type="hidden" name="subform[2][clause_is_unique]" value="1" /><input type="hidden" name="subform[2][sql_query]" value="SELECT * FROM `new`" /><input type="hidden" name="subform[2][goto]" value="sql.php" /><input type="hidden" name="subform[2][default_action]" value="insert" /><input type="hidden" name="subform[2][redirect]" value="tbl_change.php" /><input type="hidden" name="subform[2][token]" value="token" />
681 <a href="#usesubform[2]=1" class="formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" class="icon ic_b_insrow" /> Copy</span> </a>
682 <input type="hidden" class="where_clause" value="%60new%60.%60id%60+%3D+1" /></span></td><td class="edit_row_anchor center print_ignore" ><span class="nowrap"><input type="hidden" name="subform[3][db]" value="data" /><input type="hidden" name="subform[3][table]" value="new" /><input type="hidden" name="subform[3][where_clause]" value="`new`.`id` = 1" /><input type="hidden" name="subform[3][clause_is_unique]" value="1" /><input type="hidden" name="subform[3][sql_query]" value="SELECT * FROM `new`" /><input type="hidden" name="subform[3][goto]" value="sql.php" /><input type="hidden" name="subform[3][default_action]" value="update" /><input type="hidden" name="subform[3][redirect]" value="tbl_change.php" /><input type="hidden" name="subform[3][token]" value="token" />
683 <a href="#usesubform[3]=1" class="formLinkSubmit"><span class="nowrap"><img src="themes/dot.gif" title="Edit" alt="Edit" class="icon ic_b_edit" /> Edit</span> </a>
684 <input type="hidden" class="where_clause" value ="%60new%60.%60id%60+%3D+1" /></span></td><td class="center print_ignore"><input type="checkbox" id="id_rows_to_delete0_right" name="rows_to_delete[0]" class="multi_checkbox checkall" value="%60new%60.%60id%60+%3D+1" /><input type="hidden" class="condition_array" value="{"`new`.`id`":"= 1"}" /> </td>'
687 PMA\libraries\DisplayResults
::POSITION_NONE
,
688 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.'
689 . '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+'
690 . 'row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3Dnew'
691 . '%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_'
692 . 'to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure'
705 '%60new%60.%60id%60+%3D+1',
707 '`new`.`id`' => '= 1',
709 'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
710 . 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
711 . '%60new%60&goto=sql.php&default_action=update',
712 'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
713 . 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
714 . '%60new%60&goto=sql.php&default_action=insert',
716 '<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
717 . 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
718 '<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
719 . 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
720 '<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
721 . 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
722 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
723 '<td class="center print_ignore"><input type="checkbox" id="id_rows_to_'
724 . 'delete0_left" name="rows_to_delete[0]" class="multi_checkbox '
725 . 'checkall" value="%60new%60.%60id%60+%3D+1" /><input type='
726 . '"hidden" class="condition_array" value="{"`new`.`id`":'
727 . '"= 1"}" /> </td>'
733 * Test for _getCheckboxAndLinks
735 * @param string $position the position of the checkbox and links
736 * @param string $del_url delete url
737 * @param array $displayParts array with explicit indexes for all the
739 * @param string $row_no row number
740 * @param string $where_clause where clause
741 * @param string $where_clause_html url encoded where clause
742 * @param array $condition_array array of conditions in the where clause
743 * @param string $edit_url edit url
744 * @param string $copy_url copy url
745 * @param string $class css classes for the td elements
746 * @param string $edit_str text for the edit link
747 * @param string $copy_str text for the copy link
748 * @param string $del_str text for the delete link
749 * @param string $js_conf text for the JS confirmation
750 * @param string $output output of _getCheckboxAndLinks
754 * @dataProvider dataProviderForGetCheckboxAndLinks
756 public function testGetCheckboxAndLinks(
757 $position, $del_url, $displayParts, $row_no, $where_clause,
758 $where_clause_html, $condition_array, $edit_url,
759 $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf, $output
763 $this->_callPrivateFunction(
764 '_getCheckboxAndLinks',
766 $position, $del_url, $displayParts, $row_no, $where_clause,
767 $where_clause_html, $condition_array,
768 $edit_url, $copy_url, $class, $edit_str,
769 $copy_str, $del_str, $js_conf
776 * Data provider for testGetPlacedLinks
778 * @return array parameters and output
780 public function dataProviderForGetPlacedLinks()
784 PMA\libraries\DisplayResults
::POSITION_NONE
,
785 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.'
786 . '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+'
787 . 'row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3Dnew'
788 . '%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_'
789 . 'to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure'
802 '%60new%60.%60id%60+%3D+1',
804 '`new`.`id`' => '= 1',
806 'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
807 . 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
808 . '%60new%60&goto=sql.php&default_action=update',
809 'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
810 . 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
811 . '%60new%60&goto=sql.php&default_action=insert',
813 '<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
814 . 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
815 '<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
816 . 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
817 '<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
818 . 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
820 '<td class="center print_ignore"><input type="checkbox" id="id_rows_to_'
821 . 'delete0_left" name="rows_to_delete[0]" class="multi_checkbox '
822 . 'checkall" value="%60new%60.%60id%60+%3D+1" /><input type='
823 . '"hidden" class="condition_array" value="{"`new`.`id`":'
824 . '"= 1"}" /> </td>'
830 * Test for _getPlacedLinks
832 * @param string $dir the direction of links should place
833 * @param string $del_url the url for delete row
834 * @param array $displayParts which elements to display
835 * @param integer $row_no the index of current row
836 * @param string $where_clause the where clause of the sql
837 * @param string $where_clause_html the html encoded where clause
838 * @param array $condition_array array of keys (primary, unique, condition)
839 * @param string $edit_url the url for edit row
840 * @param string $copy_url the url for copy row
841 * @param string $edit_anchor_class the class for html element for edit
842 * @param string $edit_str the label for edit row
843 * @param string $copy_str the label for copy row
844 * @param string $del_str the label for delete row
845 * @param string $js_conf text for the JS confirmation
846 * @param string $output output of _getPlacedLinks
850 * @dataProvider dataProviderForGetPlacedLinks
852 public function testGetPlacedLinks(
853 $dir, $del_url, $displayParts, $row_no, $where_clause, $where_clause_html,
854 $condition_array, $edit_url, $copy_url,
855 $edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf, $output
859 $this->_callPrivateFunction(
862 $dir, $del_url, $displayParts, $row_no, $where_clause,
863 $where_clause_html, $condition_array,
864 $edit_url, $copy_url, $edit_anchor_class,
865 $edit_str, $copy_str, $del_str, $js_conf
873 * Data provider for testGetSpecialLinkUrl
875 * @return array parameters and output
877 public function dataProviderForTestGetSpecialLinkUrl()
881 'information_schema',
885 'routine_name' => 'circumference',
886 'routine_schema' => 'data',
887 'routine_type' => 'FUNCTION'
890 'db_routines.php?item_name=circumference&db=data'
891 . '&item_type=FUNCTION&server=0&lang=en'
892 . '&collation_connection=utf-8&token=token'
895 'information_schema',
899 'routine_name' => 'area',
900 'routine_schema' => 'data',
901 'routine_type' => 'PROCEDURE'
904 'db_routines.php?item_name=area&db=data'
905 . '&item_type=PROCEDURE&server=0&lang=en'
906 . '&collation_connection=utf-8&token=token'
909 'information_schema',
911 'CHARACTER_SET_NAME',
913 'table_schema' => 'information_schema',
914 'table_name' => 'CHARACTER_SETS'
917 'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60info'
918 . 'rmation_schema%60.%60CHARACTER_SETS%60&db=information_schema'
919 . '&test_name=value&server=0&lang=en'
920 . '&collation_connection=utf-8&token=token'
927 * Test _getSpecialLinkUrl
929 * @param string $db the database name
930 * @param string $table the table name
931 * @param string $column_value column value
932 * @param array $row_info information about row
933 * @param string $field_name column name
934 * @param boolean $output output of _getSpecialLinkUrl
938 * @dataProvider dataProviderForTestGetSpecialLinkUrl
940 public function testGetSpecialLinkUrl(
941 $db, $table, $column_value, $row_info, $field_name, $output
943 $GLOBALS['special_schema_links'] = array(
944 'information_schema' => array(
946 'routine_name' => array(
947 'link_param' => 'item_name',
948 'link_dependancy_params' => array(
950 'param_info' => 'db',
951 'column_name' => 'routine_schema'
954 'param_info' => 'item_type',
955 'column_name' => 'routine_type'
958 'default_page' => 'db_routines.php'
962 'column_name' => array(
963 'link_param' => array(
968 'link_dependancy_params' => array(
970 'param_info' => 'db',
971 'column_name' => 'table_schema'
974 'param_info' => array('test_name', 'value')
977 'default_page' => 'index.php'
983 $this->object->__set('db', $db);
984 $this->object->__set('table', $table);
988 $this->_callPrivateFunction(
989 '_getSpecialLinkUrl',
990 array($column_value, $row_info, $field_name)
997 * Data provider for testGetRowInfoForSpecialLinks
999 * @return array parameters and output
1001 public function dataProviderForTestGetRowInfoForSpecialLinks()
1003 $column_names = array('host', 'db', 'user', 'select_privilages');
1004 $fields_mata = array();
1006 foreach ($column_names as $column_name) {
1007 $field_meta = new stdClass();
1008 $field_meta->orgname
= $column_name;
1009 $fields_mata[] = $field_meta;
1015 count($fields_mata),
1029 'host' => 'localhost',
1030 'select_privilages' => 'Y',
1031 'db' => 'phpmyadmin',
1040 * Test _getRowInfoForSpecialLinks
1042 * @param array $fields_meta meta information about fields
1043 * @param integer $fields_count number of fields
1044 * @param array $row current row data
1045 * @param array $col_order the column order
1046 * @param boolean $output output of _getRowInfoForSpecialLinks
1050 * @dataProvider dataProviderForTestGetRowInfoForSpecialLinks
1052 public function testGetRowInfoForSpecialLinks(
1053 $fields_meta, $fields_count, $row, $col_order, $output
1055 $this->object->__set('fields_meta', $fields_meta);
1056 $this->object->__set('fields_cnt', $fields_count);
1058 $this->assertEquals(
1060 $this->_callPrivateFunction(
1061 '_getRowInfoForSpecialLinks',
1062 array($row, $col_order)
1069 * Data provider for testGetShowAllButtonForTableNavigation
1071 * @return array parameters and output
1073 public function dataProviderForTestGetShowAllCheckboxForTableNavigation()
1079 'tbl_structure.php',
1081 'SELECT * FROM `user`',
1083 . '<td><form action="sql.php" method="post">'
1084 . '<input type="hidden" name="db" value="mysql" />'
1085 . '<input type="hidden" name="table" value="user" />'
1086 . '<input type="hidden" name="lang" value="en" />'
1087 . '<input type="hidden" name="collation_connection" value="utf-8" />'
1088 . '<input type="hidden" name="token" value="token" />'
1089 . '<input type="hidden" name="sql_query" value="SELECT * FROM `user`" />'
1090 . '<input type="hidden" name="pos" value="0" />'
1091 . '<input type="hidden" name="is_browse_distinct" value="" />'
1092 . '<input type="hidden" name="session_max_rows" value="all" />'
1093 . '<input type="hidden" name="goto" value="tbl_structure.php" />'
1094 . '<input type="checkbox" name="navig" id="showAll_0"'
1095 . ' class="showAllRows" value="all" />'
1096 . '<label for="showAll_0">Show all</label></form></td>'
1103 * Test _getShowAllButtonForTableNavigation
1105 * @param string $db the database name
1106 * @param string $table the table name
1107 * @param string $goto the URL to go back in case of errors
1108 * @param int $unique_id the unique id for the results set
1109 * @param string $html_sql_query the sql encoded by html special characters
1110 * @param string $output output of _getRowInfoForSpecialLinks
1114 * @dataProvider dataProviderForTestGetShowAllCheckboxForTableNavigation
1116 public function testGetShowAllCheckboxForTableNavigation(
1117 $db, $table, $goto, $unique_id , $html_sql_query, $output
1119 $this->object->__set('db', $db);
1120 $this->object->__set('table', $table);
1121 $this->object->__set('goto', $goto);
1122 $this->object->__set('unique_id', $unique_id);
1124 $this->assertEquals(
1126 $this->_callPrivateFunction(
1127 '_getShowAllCheckboxForTableNavigation',
1128 array(false, $html_sql_query)
1135 * Data provider for testSetHighlightedColumnGlobalField
1137 * @return array parameters and output
1139 public function dataProviderForTestSetHighlightedColumnGlobalField()
1141 $parser = new PhpMyAdmin\SqlParser\
Parser(
1142 'SELECT * FROM db_name WHERE `db_name`.`tbl`.id > 0 AND `id` < 10'
1146 array('statement' => $parser->statements
[0]),
1148 'db_name' => 'true',
1158 * Test _setHighlightedColumnGlobalField
1160 * @param array $analyzed_sql the analyzed query
1161 * @param array $output setting value of _setHighlightedColumnGlobalField
1165 * @dataProvider dataProviderForTestSetHighlightedColumnGlobalField
1167 public function testSetHighlightedColumnGlobalField($analyzed_sql, $output)
1169 $this->_callPrivateFunction(
1170 '_setHighlightedColumnGlobalField',
1171 array($analyzed_sql)
1174 $this->assertEquals(
1176 $this->object->__get('highlight_columns')
1182 * Data provider for testGetPartialText
1184 * @return array parameters and output
1186 public function dataProviderForTestGetPartialText()
1189 array('P', 10, 'foo', array(false, 'foo', 3)),
1190 array('P', 1, 'foo', array(true, 'f...', 3)),
1191 array('F', 10, 'foo', array(false, 'foo', 3)),
1192 array('F', 1, 'foo', array(false, 'foo', 3))
1198 * Test _getPartialText
1200 * @param string $pftext Partial or Full text
1201 * @param integer $limitChars Partial or Full text
1202 * @param string $str the string to be tested
1203 * @param boolean $output return value of _getPartialText
1207 * @dataProvider dataProviderForTestGetPartialText
1209 public function testGetPartialText($pftext, $limitChars, $str, $output)
1211 $_SESSION['tmpval']['pftext'] = $pftext;
1212 $GLOBALS['cfg']['LimitChars'] = $limitChars;
1213 $this->assertEquals(
1215 $this->_callPrivateFunction(
1224 * Data provider for testHandleNonPrintableContents
1226 * @return array parameters and output
1228 public function dataProviderForTestHandleNonPrintableContents()
1230 $transformation_plugin = new Text_Plain_Link();
1231 $meta = new StdClass();
1232 $meta->type
= 'BLOB';
1233 $meta->orgtable
= 'bar';
1234 $url_params = array('db' => 'foo', 'table' => 'bar');
1242 'PMA_mimeDefaultFunction',
1244 'PMA_mimeDefaultFunction',
1248 '<a href="tbl_get_field.php?db=foo&table=bar&server=0'
1249 . '&lang=en&collation_connection=utf-8&token=token'
1250 . '" class="disableAjax">1001</a>'
1257 'PMA_mimeDefaultFunction',
1259 'PMA_mimeDefaultFunction',
1263 '<a href="tbl_get_field.php?db=foo&table=bar&server=0'
1264 . '&lang=en&collation_connection=utf-8&token=token'
1265 . '" class="disableAjax">0x123456</a>'
1272 'PMA_mimeDefaultFunction',
1274 'PMA_mimeDefaultFunction',
1278 '<a href="tbl_get_field.php?db=foo&table=bar&server=0'
1279 . '&lang=en&collation_connection=utf-8&token=token'
1280 . '" class="disableAjax">[BLOB - 4 B]</a>'
1287 $transformation_plugin,
1289 'PMA_mimeDefaultFunction',
1302 'PMA_mimeDefaultFunction',
1313 * Test _handleNonPrintableContents
1315 * @param boolean $display_binary show binary contents?
1316 * @param boolean $display_blob show blob contents?
1317 * @param string $category BLOB|BINARY|GEOMETRY
1318 * @param string $content the binary content
1319 * @param string $transformation_plugin transformation plugin.
1320 * Can also be the default function:
1321 * PMA_mimeDefaultFunction
1322 * @param string $transform_options transformation parameters
1323 * @param string $default_function default transformation function
1324 * @param object $meta the meta-information about the field
1325 * @param array $url_params parameters that should go to the
1327 * @param boolean $is_truncated the result is truncated or not
1328 * @param string $output the output of this function
1332 * @dataProvider dataProviderForTestHandleNonPrintableContents
1334 public function testHandleNonPrintableContents(
1335 $display_binary, $display_blob, $category, $content,
1336 $transformation_plugin, $transform_options, $default_function,
1337 $meta, $url_params, $is_truncated, $output
1339 $_SESSION['tmpval']['display_binary'] = $display_binary;
1340 $_SESSION['tmpval']['display_blob'] = $display_blob;
1341 $GLOBALS['cfg']['LimitChars'] = 50;
1342 $this->assertEquals(
1344 $this->_callPrivateFunction(
1345 '_handleNonPrintableContents',
1347 $category, $content, $transformation_plugin,
1348 $transform_options, $default_function,
1349 $meta, $url_params, &$is_truncated
1357 * Data provider for testGetDataCellForNonNumericColumns
1359 * @return array parameters and output
1361 public function dataProviderForTestGetDataCellForNonNumericColumns()
1363 $transformation_plugin = new Text_Plain_Link();
1364 $meta = new StdClass();
1366 $meta->table
= 'tbl';
1367 $meta->orgtable
= 'tbl';
1368 $meta->type
= 'BLOB';
1369 $meta->flags
= 'blob binary';
1370 $meta->name
= 'tblob';
1371 $meta->orgname
= 'tblob';
1373 $meta2 = new StdClass();
1375 $meta2->table
= 'tbl';
1376 $meta2->orgtable
= 'tbl';
1377 $meta2->type
= 'string';
1379 $meta2->decimals
= 0;
1380 $meta2->name
= 'varchar';
1381 $meta2->orgname
= 'varchar';
1382 $url_params = array('db' => 'foo', 'table' => 'tbl');
1393 'PMA_mimeDefaultFunction',
1394 'PMA_mimeDefaultFunction',
1395 array('https://www.example.com/'),
1400 '<td class="left hex"><a href="tbl_get_field.php?'
1401 . 'db=foo&table=tbl&server=0&lang=en'
1402 . '&collation_connection=utf-8&token=token'
1404 . 'class="disableAjax">[BLOB - 4 B]</a></td>'
1414 $transformation_plugin,
1415 'PMA_mimeDefaultFunction',
1421 '<td class="left grid_edit transformed hex">'
1432 $transformation_plugin,
1433 'PMA_mimeDefaultFunction',
1439 '<td data-decimals="0" data-type="string" '
1440 . 'class="grid_edit null"><i>NULL</i></td>'
1450 'PMA_mimeDefaultFunction',
1451 'PMA_mimeDefaultFunction',
1457 '<td data-decimals="0" data-type="string" '
1458 . 'data-originallength="11" '
1459 . 'class="grid_edit ">foo bar baz</td>' . "\n"
1466 * Test _getDataCellForNonNumericColumns
1468 * @param boolean $protectBinary all|blob|noblob|no
1469 * @param string $column the relevant column in data row
1470 * @param string $class the html class for column
1471 * @param object $meta the meta-information about the field
1472 * @param array $map the list of relations
1473 * @param array $_url_params the parameters for generate url
1474 * @param boolean $condition_field the column should highlighted
1476 * @param string $transformation_plugin the name of transformation function
1477 * @param string $default_function the default transformation function
1478 * @param string $transform_options the transformation parameters
1479 * @param boolean $is_field_truncated is data truncated due to LimitChars
1480 * @param array $analyzed_sql_results the analyzed query
1481 * @param integer $dt_result the link id associated to the query
1482 * which results have to be displayed
1483 * @param integer $col_index the column index
1484 * @param string $output the output of this function
1488 * @dataProvider dataProviderForTestGetDataCellForNonNumericColumns
1490 public function testGetDataCellForNonNumericColumns(
1491 $protectBinary, $column, $class, $meta, $map,
1492 $_url_params, $condition_field, $transformation_plugin,
1493 $default_function, $transform_options, $is_field_truncated,
1494 $analyzed_sql_results, $dt_result, $col_index, $output
1496 $_SESSION['tmpval']['display_binary'] = true;
1497 $_SESSION['tmpval']['display_blob'] = false;
1498 $_SESSION['tmpval']['relational_display'] = false;
1499 $GLOBALS['cfg']['LimitChars'] = 50;
1500 $GLOBALS['cfg']['ProtectBinary'] = $protectBinary;
1501 $this->assertEquals(
1503 $this->_callPrivateFunction(
1504 '_getDataCellForNonNumericColumns',
1506 $column, $class, $meta, $map, $_url_params, $condition_field,
1507 $transformation_plugin, $default_function, $transform_options,
1508 $is_field_truncated, $analyzed_sql_results, &$dt_result, $col_index