Merge remote-tracking branch 'security/QA_4_7-security' into QA_4_7-security
[phpmyadmin.git] / test / classes / DisplayResultsTest.php
blobce6b6a7bd43ee89b741939306f54accc52903cd0
1 <?php
2 /**
3 * Tests for displaying results
5 * @package PhpMyAdmin-test
6 */
8 /*
9 * Include to 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';
17 /**
18 * Test cases for displaying results.
20 * @package PhpMyAdmin-test
22 class DisplayResultsTest extends PMATestCase
24 /**
25 * @access protected
27 protected $object;
29 /**
30 * Sets up the fixture, for example, opens a network connection.
31 * This method is called before a test is executed.
33 * @access protected
34 * @return void
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()
47 ->getMock();
49 $dbi->expects($this->any())->method('fieldFlags')
50 ->will($this->returnArgument(1));
52 $GLOBALS['dbi'] = $dbi;
55 /**
56 * Tears down the fixture, for example, closes a network connection.
57 * This method is called after a test is executed.
59 * @access protected
60 * @return void
62 protected function tearDown()
64 unset($this->object);
67 /**
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);
83 /**
84 * Test for _isSelect function
86 * @return void
88 public function testisSelect()
90 $parser = new \PhpMyAdmin\SqlParser\Parser('SELECT * FROM pma');
91 $this->assertTrue(
92 $this->_callPrivateFunction(
93 '_isSelect',
94 array(
95 array(
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
112 * method
114 * @return void
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';
124 $this->assertEquals(
125 $output,
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()
140 return array(
141 array(
142 'btn',
143 'Submit',
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
165 * @return void
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.
185 $this->assertEquals(
186 $output,
187 str_word_count(
188 $this->_callPrivateFunction(
189 '_getTableNavigation',
190 array(
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()
207 return array(
208 array(
211 false,
212 '310'
218 * Data provider for testGetClassesForColumn
220 * @return array parameters and output
222 public function dataProviderForTestGetClassesForColumn()
224 return array(
225 array(
226 'grid_edit',
227 'not_null',
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
246 * @return void
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;
257 $this->assertEquals(
258 $output,
259 $this->_callPrivateFunction(
260 '_getClassesForColumn',
261 array(
262 $grid_edit_class, $not_null_class, $relation_class,
263 $hide_class, $field_type_class
270 * Test for _getClassForDateTimeRelatedFields - case 1
272 * @return void
274 public function testGetClassForDateTimeRelatedFieldsCase1()
276 $this->assertEquals(
277 'datetimefield',
278 $this->_callPrivateFunction(
279 '_getClassForDateTimeRelatedFields',
280 array(PMA\libraries\DisplayResults::DATETIME_FIELD)
286 * Test for _getClassForDateTimeRelatedFields - case 2
288 * @return void
290 public function testGetClassForDateTimeRelatedFieldsCase2()
292 $this->assertEquals(
293 'datefield',
294 $this->_callPrivateFunction(
295 '_getClassForDateTimeRelatedFields',
296 array(PMA\libraries\DisplayResults::DATE_FIELD)
302 * Test for _getClassForDateTimeRelatedFields - case 3
304 * @return void
306 public function testGetClassForDateTimeRelatedFieldsCase3()
308 $this->assertEquals(
309 'text',
310 $this->_callPrivateFunction(
311 '_getClassForDateTimeRelatedFields',
312 array(PMA\libraries\DisplayResults::STRING_FIELD)
318 * Test for _getOffsets - case 1
320 * @return void
322 public function testGetOffsetsCase1()
324 $_SESSION['tmpval']['max_rows'] = PMA\libraries\DisplayResults::ALL_ROWS;
325 $this->assertEquals(
326 array(0, 0),
327 $this->_callPrivateFunction('_getOffsets', array())
332 * Test for _getOffsets - case 2
334 * @return void
336 public function testGetOffsetsCase2()
338 $_SESSION['tmpval']['max_rows'] = 5;
339 $_SESSION['tmpval']['pos'] = 4;
340 $this->assertEquals(
341 array(9, 0),
342 $this->_callPrivateFunction('_getOffsets', array())
347 * Data provider for testGetCheckboxForMultiRowSubmissions
349 * @return array parameters and output
351 public function dataProviderForGetCheckboxForMultiRowSubmissions()
353 return array(
354 array(
355 'sql.php?db=data&amp;table=new&amp;sql_query=DELETE+FROM+%60data%60'
356 . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&amp;message_to_show='
357 . 'The+row+has+been+deleted&amp;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_'
360 . 'structure.php',
361 array(
362 'edit_lnk' => 'ur',
363 'del_lnk' => 'dr',
364 'sort_lnk' => '0',
365 'nav_bar' => '1',
366 'bkm_form' => '1',
367 'text_btn' => '1',
368 'pview_lnk' => '1'
371 '%60new%60.%60id%60+%3D+1',
372 array('`new`.`id`' => '= 1'),
373 '[%_PMA_CHECKBOX_DIR_%]',
374 'klass',
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="{&quot;`new`.`id`&quot;:&quot;= 1&quot;}" /> '
381 . '</td>'
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
399 * @return void
401 * @dataProvider dataProviderForGetCheckboxForMultiRowSubmissions
403 public function testGetCheckboxForMultiRowSubmissions(
404 $del_url, $displayParts, $row_no, $where_clause_html, $condition_array,
405 $id_suffix, $class, $output
407 $this->assertEquals(
408 $output,
409 $this->_callPrivateFunction(
410 '_getCheckboxForMultiRowSubmissions',
411 array(
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()
426 return array(
427 array(
428 'tbl_change.php?db=Data&amp;table=customer&amp;where_clause=%60'
429 . 'customer%60.%60id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query='
430 . 'SELECT+%2A+FROM+%60customer%60&amp;goto=sql.php&amp;default_'
431 . 'action=update',
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
454 * @return void
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;
464 $this->assertEquals(
465 $output,
466 $this->_callPrivateFunction(
467 '_getEditLink',
468 array(
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()
482 return array(
483 array(
484 'tbl_change.php?db=Data&amp;table=customer&amp;where_clause=%60cust'
485 . 'omer%60.%60id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query='
486 . 'SELECT+%2A+FROM+%60customer%60&amp;goto=sql.php&amp;default_'
487 . 'action=insert',
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',
492 'klass',
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
510 * @return void
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;
520 $this->assertEquals(
521 $output,
522 $this->_callPrivateFunction(
523 '_getCopyLink',
524 array(
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()
538 return array(
539 array(
540 'sql.php?db=Data&amp;table=customer&amp;sql_query=DELETE+FROM+%60'
541 . 'Data%60.%60customer%60+WHERE+%60customer%60.%60id%60+%3D+1&amp;'
542 . 'message_to_show=The+row+has+been+deleted&amp;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',
549 'klass',
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&amp;table=customer&amp;sql_query=SELECT+%2A+FROM+%60customer%60&amp;message_to_show=The+row+has+been+deleted&amp;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
566 * @return void
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;
576 $this->assertEquals(
577 $output,
578 $this->_callPrivateFunction(
579 '_getDeleteLink',
580 array(
581 $del_url, $del_str, $js_conf, $class
588 * Data provider for testGetCheckboxAndLinks
590 * @return array parameters and output
592 public function dataProviderForGetCheckboxAndLinks()
594 return array(
595 array(
596 PMA\libraries\DisplayResults::POSITION_LEFT,
597 'sql.php?db=data&amp;table=new&amp;sql_query=DELETE+FROM+%60data'
598 . '%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&amp;message_to_show='
599 . 'The+row+has+been+deleted&amp;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',
603 array(
604 'edit_lnk' => 'ur',
605 'del_lnk' => 'dr',
606 'sort_lnk' => '0',
607 'nav_bar' => '1',
608 'bkm_form' => '1',
609 'text_btn' => '1',
610 'pview_lnk' => '1'
613 '`new`.`id` = 1',
614 '%60new%60.%60id%60+%3D+1',
615 array(
616 '`new`.`id`' => '= 1',
618 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.'
619 . '%60id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+'
620 . 'FROM+%60new%60&amp;goto=sql.php&amp;default_action=update',
621 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.'
622 . '%60id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+'
623 . 'FROM+%60new%60&amp;goto=sql.php&amp;default_action=insert',
624 'edit_row_anchor',
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="{&quot;`new`.`id`&quot;:&quot;= 1&quot;}" /> </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&amp;table=new&amp;sql_query=SELECT+%2A+FROM+%60new%60&amp;message_to_show=The+row+has+been+deleted&amp;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>'
641 array(
642 PMA\libraries\DisplayResults::POSITION_RIGHT,
643 'sql.php?db=data&amp;table=new&amp;sql_query=DELETE+FROM+%60data%60'
644 . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&amp;message_to_show='
645 . 'The+row+has+been+deleted&amp;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_'
648 . 'structure.php',
649 array(
650 'edit_lnk' => 'ur',
651 'del_lnk' => 'dr',
652 'sort_lnk' => '0',
653 'nav_bar' => '1',
654 'bkm_form' => '1',
655 'text_btn' => '1',
656 'pview_lnk' => '1'
659 '`new`.`id` = 1',
660 '%60new%60.%60id%60+%3D+1',
661 array(
662 '`new`.`id`' => '= 1',
664 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.'
665 . '%60id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+'
666 . 'FROM+%60new%60&amp;goto=sql.php&amp;default_action=update',
667 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.'
668 . '%60id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+'
669 . 'FROM+%60new%60&amp;goto=sql.php&amp;default_action=insert',
670 'edit_row_anchor',
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&amp;table=new&amp;sql_query=SELECT+%2A+FROM+%60new%60&amp;message_to_show=The+row+has+been+deleted&amp;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="{&quot;`new`.`id`&quot;:&quot;= 1&quot;}" /> </td>'
686 array(
687 PMA\libraries\DisplayResults::POSITION_NONE,
688 'sql.php?db=data&amp;table=new&amp;sql_query=DELETE+FROM+%60data%60.'
689 . '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&amp;message_to_show=The+'
690 . 'row+has+been+deleted&amp;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'
693 . '.php',
694 array(
695 'edit_lnk' => 'ur',
696 'del_lnk' => 'dr',
697 'sort_lnk' => '0',
698 'nav_bar' => '1',
699 'bkm_form' => '1',
700 'text_btn' => '1',
701 'pview_lnk' => '1'
704 '`new`.`id` = 1',
705 '%60new%60.%60id%60+%3D+1',
706 array(
707 '`new`.`id`' => '= 1',
709 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.%60'
710 . 'id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+FROM+'
711 . '%60new%60&amp;goto=sql.php&amp;default_action=update',
712 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.%60'
713 . 'id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+FROM+'
714 . '%60new%60&amp;goto=sql.php&amp;default_action=insert',
715 'edit_row_anchor',
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="{&quot;`new`.`id`&quot;:'
727 . '&quot;= 1&quot;}" /> </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
738 * display elements
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
752 * @return void
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
761 $this->assertEquals(
762 $output,
763 $this->_callPrivateFunction(
764 '_getCheckboxAndLinks',
765 array(
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()
782 return array(
783 array(
784 PMA\libraries\DisplayResults::POSITION_NONE,
785 'sql.php?db=data&amp;table=new&amp;sql_query=DELETE+FROM+%60data%60.'
786 . '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&amp;message_to_show=The+'
787 . 'row+has+been+deleted&amp;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'
790 . '.php',
791 array(
792 'edit_lnk' => 'ur',
793 'del_lnk' => 'dr',
794 'sort_lnk' => '0',
795 'nav_bar' => '1',
796 'bkm_form' => '1',
797 'text_btn' => '1',
798 'pview_lnk' => '1'
801 '`new`.`id` = 1',
802 '%60new%60.%60id%60+%3D+1',
803 array(
804 '`new`.`id`' => '= 1',
806 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.%60'
807 . 'id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+FROM+'
808 . '%60new%60&amp;goto=sql.php&amp;default_action=update',
809 'tbl_change.php?db=data&amp;table=new&amp;where_clause=%60new%60.%60'
810 . 'id%60+%3D+1&amp;clause_is_unique=1&amp;sql_query=SELECT+%2A+FROM+'
811 . '%60new%60&amp;goto=sql.php&amp;default_action=insert',
812 'edit_row_anchor',
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>',
819 null,
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="{&quot;`new`.`id`&quot;:'
824 . '&quot;= 1&quot;}" /> </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
848 * @return void
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
857 $this->assertEquals(
858 $output,
859 $this->_callPrivateFunction(
860 '_getPlacedLinks',
861 array(
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()
879 return array(
880 array(
881 'information_schema',
882 'routines',
883 'circumference',
884 array(
885 'routine_name' => 'circumference',
886 'routine_schema' => 'data',
887 'routine_type' => 'FUNCTION'
889 'routine_name',
890 'db_routines.php?item_name=circumference&db=data'
891 . '&item_type=FUNCTION&server=0&lang=en'
892 . '&collation_connection=utf-8&token=token'
894 array(
895 'information_schema',
896 'routines',
897 'area',
898 array(
899 'routine_name' => 'area',
900 'routine_schema' => 'data',
901 'routine_type' => 'PROCEDURE'
903 'routine_name',
904 'db_routines.php?item_name=area&db=data'
905 . '&item_type=PROCEDURE&server=0&lang=en'
906 . '&collation_connection=utf-8&token=token'
908 array(
909 'information_schema',
910 'columns',
911 'CHARACTER_SET_NAME',
912 array(
913 'table_schema' => 'information_schema',
914 'table_name' => 'CHARACTER_SETS'
916 'column_name',
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
936 * @return void
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(
945 'routines' => array(
946 'routine_name' => array(
947 'link_param' => 'item_name',
948 'link_dependancy_params' => array(
949 0 => array(
950 'param_info' => 'db',
951 'column_name' => 'routine_schema'
953 1 => array(
954 'param_info' => 'item_type',
955 'column_name' => 'routine_type'
958 'default_page' => 'db_routines.php'
961 'columns' => array(
962 'column_name' => array(
963 'link_param' => array(
964 'sql_query',
965 'table_schema',
966 'table_name'
968 'link_dependancy_params' => array(
969 0 => array(
970 'param_info' => 'db',
971 'column_name' => 'table_schema'
973 1 => array(
974 'param_info' => array('test_name', 'value')
977 'default_page' => 'index.php'
983 $this->object->__set('db', $db);
984 $this->object->__set('table', $table);
986 $this->assertEquals(
987 $output,
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;
1012 return array(
1013 array(
1014 $fields_mata,
1015 count($fields_mata),
1016 array(
1017 0 => 'localhost',
1018 1 => 'phpmyadmin',
1019 2 => 'pmauser',
1020 3 => 'Y'
1022 array(
1023 0 => '0',
1024 1 => '3',
1025 2 => '1',
1026 3 => '2'
1028 array(
1029 'host' => 'localhost',
1030 'select_privilages' => 'Y',
1031 'db' => 'phpmyadmin',
1032 'user' => 'pmauser'
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
1048 * @return void
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(
1059 $output,
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()
1075 return array(
1076 array(
1077 'mysql',
1078 'user',
1079 'tbl_structure.php',
1081 'SELECT * FROM `user`',
1082 "\n"
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
1112 * @return void
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(
1125 $output,
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'
1144 return array(
1145 array(
1146 array('statement' => $parser->statements[0]),
1147 array(
1148 'db_name' => 'true',
1149 'tbl' => 'true',
1150 'id' => 'true',
1158 * Test _setHighlightedColumnGlobalField
1160 * @param array $analyzed_sql the analyzed query
1161 * @param array $output setting value of _setHighlightedColumnGlobalField
1163 * @return void
1165 * @dataProvider dataProviderForTestSetHighlightedColumnGlobalField
1167 public function testSetHighlightedColumnGlobalField($analyzed_sql, $output)
1169 $this->_callPrivateFunction(
1170 '_setHighlightedColumnGlobalField',
1171 array($analyzed_sql)
1174 $this->assertEquals(
1175 $output,
1176 $this->object->__get('highlight_columns')
1182 * Data provider for testGetPartialText
1184 * @return array parameters and output
1186 public function dataProviderForTestGetPartialText()
1188 return array(
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
1205 * @return void
1207 * @dataProvider dataProviderForTestGetPartialText
1209 public function testGetPartialText($pftext, $limitChars, $str, $output)
1211 $_SESSION['tmpval']['pftext'] = $pftext;
1212 $GLOBALS['cfg']['LimitChars'] = $limitChars;
1213 $this->assertEquals(
1214 $output,
1215 $this->_callPrivateFunction(
1216 '_getPartialText',
1217 array($str)
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');
1236 return array(
1237 array(
1238 true,
1239 true,
1240 'BLOB',
1241 '1001',
1242 'PMA_mimeDefaultFunction',
1244 'PMA_mimeDefaultFunction',
1245 $meta,
1246 $url_params,
1247 null,
1248 '<a href="tbl_get_field.php?db=foo&amp;table=bar&amp;server=0'
1249 . '&amp;lang=en&amp;collation_connection=utf-8&amp;token=token'
1250 . '" class="disableAjax">1001</a>'
1252 array(
1253 true,
1254 true,
1255 'BLOB',
1256 hex2bin('123456'),
1257 'PMA_mimeDefaultFunction',
1259 'PMA_mimeDefaultFunction',
1260 $meta,
1261 $url_params,
1262 null,
1263 '<a href="tbl_get_field.php?db=foo&amp;table=bar&amp;server=0'
1264 . '&amp;lang=en&amp;collation_connection=utf-8&amp;token=token'
1265 . '" class="disableAjax">0x123456</a>'
1267 array(
1268 true,
1269 false,
1270 'BLOB',
1271 '1001',
1272 'PMA_mimeDefaultFunction',
1274 'PMA_mimeDefaultFunction',
1275 $meta,
1276 $url_params,
1277 null,
1278 '<a href="tbl_get_field.php?db=foo&amp;table=bar&amp;server=0'
1279 . '&amp;lang=en&amp;collation_connection=utf-8&amp;token=token'
1280 . '" class="disableAjax">[BLOB - 4 B]</a>'
1282 array(
1283 false,
1284 false,
1285 'BINARY',
1286 '1001',
1287 $transformation_plugin,
1289 'PMA_mimeDefaultFunction',
1290 $meta,
1291 $url_params,
1292 null,
1293 '1001'
1295 array(
1296 false,
1297 true,
1298 'GEOMETRY',
1299 null,
1302 'PMA_mimeDefaultFunction',
1303 $meta,
1304 $url_params,
1305 null,
1306 '[GEOMETRY - NULL]'
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
1326 * download link
1327 * @param boolean $is_truncated the result is truncated or not
1328 * @param string $output the output of this function
1330 * @return void
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(
1343 $output,
1344 $this->_callPrivateFunction(
1345 '_handleNonPrintableContents',
1346 array(
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();
1365 $meta->db = 'foo';
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();
1374 $meta2->db = 'foo';
1375 $meta2->table = 'tbl';
1376 $meta2->orgtable = 'tbl';
1377 $meta2->type = 'string';
1378 $meta2->flags = '';
1379 $meta2->decimals = 0;
1380 $meta2->name = 'varchar';
1381 $meta2->orgname = 'varchar';
1382 $url_params = array('db' => 'foo', 'table' => 'tbl');
1384 return array(
1385 array(
1386 'all',
1387 '1001',
1388 'grid_edit',
1389 $meta,
1390 array(),
1391 $url_params,
1392 false,
1393 'PMA_mimeDefaultFunction',
1394 'PMA_mimeDefaultFunction',
1395 array('https://www.example.com/'),
1396 false,
1397 array(),
1399 'binary',
1400 '<td class="left hex"><a href="tbl_get_field.php?'
1401 . 'db=foo&amp;table=tbl&amp;server=0&amp;lang=en'
1402 . '&amp;collation_connection=utf-8&amp;token=token'
1403 . '" '
1404 . 'class="disableAjax">[BLOB - 4 B]</a></td>'
1406 array(
1407 'noblob',
1408 '1001',
1409 'grid_edit',
1410 $meta,
1411 array(),
1412 $url_params,
1413 false,
1414 $transformation_plugin,
1415 'PMA_mimeDefaultFunction',
1417 false,
1418 array(),
1420 'binary',
1421 '<td class="left grid_edit transformed hex">'
1422 . '1001</td>'
1424 array(
1425 'noblob',
1426 null,
1427 'grid_edit',
1428 $meta2,
1429 array(),
1430 $url_params,
1431 false,
1432 $transformation_plugin,
1433 'PMA_mimeDefaultFunction',
1435 false,
1436 array(),
1439 '<td data-decimals="0" data-type="string" '
1440 . 'class="grid_edit null"><i>NULL</i></td>'
1442 array(
1443 'all',
1444 'foo bar baz',
1445 'grid_edit',
1446 $meta2,
1447 array(),
1448 $url_params,
1449 false,
1450 'PMA_mimeDefaultFunction',
1451 'PMA_mimeDefaultFunction',
1453 false,
1454 array(),
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
1475 * or not
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
1486 * @return void
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(
1502 $output,
1503 $this->_callPrivateFunction(
1504 '_getDataCellForNonNumericColumns',
1505 array(
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