1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
|
<?php
/**
* Tests for displaying results
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
use PMA\libraries\plugins\transformations\Text_Plain_Link;
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/js_escape.lib.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/string.lib.php';
require_once 'test/PMATestCase.php';
/**
* Test cases for displaying results.
*
* @package PhpMyAdmin-test
*/
class DisplayResultsTest extends PMATestCase
{
/**
* @access protected
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
$GLOBALS['server'] = 0;
$this->object = new PMA\libraries\DisplayResults('as', '', '', '');
$GLOBALS['PMA_Config'] = new PMA\libraries\Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['collation_connection'] = 'utf-8';
$_SESSION[' HMAC_secret '] = 'test';
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())->method('fieldFlags')
->will($this->returnArgument(1));
$GLOBALS['dbi'] = $dbi;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
* @return void
*/
protected function tearDown()
{
unset($this->object);
}
/**
* Call private functions by setting visibility to public.
*
* @param string $name method name
* @param array $params parameters for the invocation
*
* @return the output from the private method.
*/
private function _callPrivateFunction($name, $params)
{
$class = new ReflectionClass('PMA\libraries\DisplayResults');
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($this->object, $params);
}
/**
* Test for _isSelect function
*
* @return void
*/
public function testisSelect()
{
$parser = new \SqlParser\Parser('SELECT * FROM pma');
$this->assertTrue(
$this->_callPrivateFunction(
'_isSelect',
array(
array(
'statement' => $parser->statements[0],
'select_from' => true,
),
)
)
);
}
/**
* Test for navigation buttons
*
* @param string $caption iconic caption for button
* @param string $title text for button
* @param integer $pos position for next query
* @param string $html_sql_query query ready for display
* @param string $output output from the _getTableNavigationButton
* method
*
* @return void
*
* @dataProvider providerForTestGetTableNavigationButton
*/
public function testGetTableNavigationButton(
$caption, $title, $pos, $html_sql_query, $output
) {
$GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
$_SESSION[' PMA_token '] = 'token';
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getTableNavigationButton',
array(&$caption, $title, $pos, $html_sql_query, true)
)
);
}
/**
* Provider for testGetTableNavigationButton
*
* @return array array data for testGetTableNavigationButton
*/
public function providerForTestGetTableNavigationButton()
{
return array(
array(
'btn',
'Submit',
1,
'SELECT * FROM `pma_bookmark` WHERE 1',
'<td><form action="sql.php" method="post" >'
. '<input type="hidden" name="db" value="as" />'
. '<input type="hidden" name="lang" value="en" />'
. '<input type="hidden" name="collation_connection" value="utf-8" />'
. '<input type="hidden" name="token" value="token" />'
. '<input type="hidden" name="sql_query" value="SELECT * '
. 'FROM `pma_bookmark` WHERE 1" />'
. '<input type="hidden" name="pos" value="1" />'
. '<input type="hidden" name="is_browse_distinct" value="" />'
. '<input type="hidden" name="goto" value="" />'
. '<input type="submit" name="navig" class="ajax" '
. 'value="btn" title="Submit" /></form></td>'
)
);
}
/**
* Test for table navigation
*
* @return void
*
* @dataProvider providerForTestGetTableNavigation
*/
public function testGetTableNavigation(
// $pos_next, $pos_prev, $is_innodb, $output
) {
$_SESSION['tmpval']['max_rows'] = '20';
$_SESSION['tmpval']['pos'] = true;
$GLOBALS['num_rows'] = '20';
$GLOBALS['unlim_num_rows'] = '50';
$GLOBALS['cfg']['ShowAll'] = true;
$_SESSION['tmpval']['repeat_cells'] = '1';
/**
* FIXME Counting words of a generated large HTML is not a good way
* of testing IMO. Introduce more granular assertions that assert for
* existence of important content inside the generated HTML.
*/
/*
$this->assertEquals(
$output,
str_word_count(
$this->_callPrivateFunction(
'_getTableNavigation',
array(
$pos_next, $pos_prev, $is_innodb
)
)
)
);
*/
$this->markTestIncomplete('Not yet implemented!');
}
/**
* Provider for testing table navigation
*
* @return array data for testGetTableNavigation
*/
public function providerForTestGetTableNavigation()
{
return array(
array(
21,
41,
false,
'310'
)
);
}
/**
* Data provider for testGetClassesForColumn
*
* @return array parameters and output
*/
public function dataProviderForTestGetClassesForColumn()
{
return array(
array(
'grid_edit',
'not_null',
'',
'',
'',
'data grid_edit not_null '
)
);
}
/**
* Test for _getClassesForColumn
*
* @param string $grid_edit_class the class for all editable columns
* @param string $not_null_class the class for not null columns
* @param string $relation_class the class for relations in a column
* @param string $hide_class the class for visibility of a column
* @param string $field_type_class the class related to type of the field
* @param string $output output of__getResettedClassForInlineEdit
*
* @return void
*
* @dataProvider dataProviderForTestGetClassesForColumn
*/
public function testGetClassesForColumn(
$grid_edit_class, $not_null_class, $relation_class,
$hide_class, $field_type_class, $output
) {
$GLOBALS['cfg']['BrowsePointerEnable'] = true;
$GLOBALS['cfg']['BrowseMarkerEnable'] = true;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getClassesForColumn',
array(
$grid_edit_class, $not_null_class, $relation_class,
$hide_class, $field_type_class
)
)
);
}
/**
* Test for _getClassForDateTimeRelatedFields - case 1
*
* @return void
*/
public function testGetClassForDateTimeRelatedFieldsCase1()
{
$this->assertEquals(
'datetimefield',
$this->_callPrivateFunction(
'_getClassForDateTimeRelatedFields',
array(PMA\libraries\DisplayResults::DATETIME_FIELD)
)
);
}
/**
* Test for _getClassForDateTimeRelatedFields - case 2
*
* @return void
*/
public function testGetClassForDateTimeRelatedFieldsCase2()
{
$this->assertEquals(
'datefield',
$this->_callPrivateFunction(
'_getClassForDateTimeRelatedFields',
array(PMA\libraries\DisplayResults::DATE_FIELD)
)
);
}
/**
* Test for _getClassForDateTimeRelatedFields - case 3
*
* @return void
*/
public function testGetClassForDateTimeRelatedFieldsCase3()
{
$this->assertEquals(
'text',
$this->_callPrivateFunction(
'_getClassForDateTimeRelatedFields',
array(PMA\libraries\DisplayResults::STRING_FIELD)
)
);
}
/**
* Test for _getOffsets - case 1
*
* @return void
*/
public function testGetOffsetsCase1()
{
$_SESSION['tmpval']['max_rows'] = PMA\libraries\DisplayResults::ALL_ROWS;
$this->assertEquals(
array(0, 0),
$this->_callPrivateFunction('_getOffsets', array())
);
}
/**
* Test for _getOffsets - case 2
*
* @return void
*/
public function testGetOffsetsCase2()
{
$_SESSION['tmpval']['max_rows'] = 5;
$_SESSION['tmpval']['pos'] = 4;
$this->assertEquals(
array(9, 0),
$this->_callPrivateFunction('_getOffsets', array())
);
}
/**
* Data provider for testGetCheckboxForMultiRowSubmissions
*
* @return array parameters and output
*/
public function dataProviderForGetCheckboxForMultiRowSubmissions()
{
return array(
array(
'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60'
. '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
. 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
. 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message'
. '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_'
. 'structure.php%26token%3Dd1aecb47ef7c081e068e7008b38a5d76&'
. 'token=d1aecb47ef7c081e068e7008b38a5d76',
array(
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
'sort_lnk' => '0',
'nav_bar' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'%60new%60.%60id%60+%3D+1',
array('`new`.`id`' => '= 1'),
'[%_PMA_CHECKBOX_DIR_%]',
'odd',
'<td class="odd" class="center print_ignore"><input type'
. '="checkbox" id="id_rows_to_delete0[%_PMA_CHECKBOX_DIR_%]" name='
. '"rows_to_delete[0]" class="multi_checkbox checkall" value="%60'
. 'new%60.%60id%60+%3D+1" /><input type="hidden" class="condition_'
. 'array" value="{"`new`.`id`":"= 1"}" /> '
. '</td>'
)
);
}
/**
* Test for _getCheckboxForMultiRowSubmissions
*
* @param string $del_url delete url
* @param array $displayParts array with explicit indexes for all
* the display elements
* @param string $row_no the row number
* @param string $where_clause_html url encoded where clause
* @param array $condition_array array of conditions in the where clause
* @param string $id_suffix suffix for the id
* @param string $class css classes for the td element
* @param string $output output of _getCheckboxForMultiRowSubmissions
*
* @return void
*
* @dataProvider dataProviderForGetCheckboxForMultiRowSubmissions
*/
public function testGetCheckboxForMultiRowSubmissions(
$del_url, $displayParts, $row_no, $where_clause_html, $condition_array,
$id_suffix, $class, $output
) {
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getCheckboxForMultiRowSubmissions',
array(
$del_url, $displayParts, $row_no, $where_clause_html,
$condition_array, $id_suffix, $class
)
)
);
}
/**
* Data provider for testGetEditLink
*
* @return array parameters and output
*/
public function dataProviderForGetEditLink()
{
return array(
array(
'tbl_change.php?db=Data&table=customer&where_clause=%60'
. 'customer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
. 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_'
. 'action=update&token=bbd5003198a3bd856b21d9607d6c6a1e',
'odd edit_row_anchor',
'<span class="nowrap"><img src="themes/dot.gif" title="Edit" alt='
. '"Edit" class="icon ic_b_edit" /> Edit</span>',
'`customer`.`id` = 1',
'%60customer%60.%60id%60+%3D+1',
'<td class="odd edit_row_anchor center print_ignore" >'
. '<span class="nowrap">' . "\n"
. '<a href="tbl_change.php?db=Data&table=customer&where_'
. 'clause=%60customer%60.%60id%60+%3D+1&clause_is_unique=1&'
. 'sql_query=SELECT+%2A+FROM+%60customer%60&goto=sql.php&'
. 'default_action=update&token=bbd5003198a3bd856b21d9607d6c6a1e"'
. ' ><span class="nowrap"><img src="themes/dot.gif" title="Edit" '
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span></a>' . "\n"
. '<input type="hidden" class="where_clause" value ="%60customer'
. '%60.%60id%60+%3D+1" /></span></td>'
)
);
}
/**
* Test for _getEditLink
*
* @param string $edit_url edit url
* @param string $class css classes for td element
* @param string $edit_str text for the edit link
* @param string $where_clause where clause
* @param string $where_clause_html url encoded where clause
* @param string $output output of _getEditLink
*
* @return void
*
* @dataProvider dataProviderForGetEditLink
*/
public function testGetEditLink(
$edit_url, $class, $edit_str, $where_clause, $where_clause_html, $output
) {
$GLOBALS['cfg']['ActionLinksMode'] = 'both';
$GLOBALS['cfg']['LinkLengthLimit'] = 1000;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getEditLink',
array(
$edit_url, $class, $edit_str, $where_clause, $where_clause_html
)
)
);
}
/**
* Data provider for testGetCopyLink
*
* @return array parameters and output
*/
public function dataProviderForGetCopyLink()
{
return array(
array(
'tbl_change.php?db=Data&table=customer&where_clause=%60cust'
. 'omer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
. 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_'
. 'action=insert&token=f597309d3a066c3c81a6cb015a79636d',
'<span class="nowrap"><img src="themes/dot.gif" title="Copy" alt'
. '="Copy" class="icon ic_b_insrow" /> Copy</span>',
'`customer`.`id` = 1',
'%60customer%60.%60id%60+%3D+1',
'odd',
'<td class="odd center print_ignore" ><span class='
. '"nowrap">' . "\n"
. '<a href="tbl_change.php?db=Data&table=customer&where_'
. 'clause=%60customer%60.%60id%60+%3D+1&clause_is_unique=1&'
. 'sql_query=SELECT+%2A+FROM+%60customer%60&goto=sql.php&'
. 'default_action=insert&token=f597309d3a066c3c81a6cb015a79636d"'
. ' ><span class="nowrap"><img src="themes/dot.gif" title="Copy" '
. 'alt="Copy" class="icon ic_b_insrow" /> Copy</span></a>' . "\n"
. '<input type="hidden" class="where_clause" value="%60customer%60'
. '.%60id%60+%3D+1" /></span></td>'
)
);
}
/**
* Test for _getCopyLink
*
* @param string $copy_url copy url
* @param string $copy_str text for the copy link
* @param string $where_clause where clause
* @param string $where_clause_html url encoded where clause
* @param string $class css classes for the td element
* @param string $output output of _getCopyLink
*
* @return void
*
* @dataProvider dataProviderForGetCopyLink
*/
public function testGetCopyLink(
$copy_url, $copy_str, $where_clause, $where_clause_html, $class, $output
) {
$GLOBALS['cfg']['ActionLinksMode'] = 'both';
$GLOBALS['cfg']['LinkLengthLimit'] = 1000;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getCopyLink',
array(
$copy_url, $copy_str, $where_clause, $where_clause_html, $class
)
)
);
}
/**
* Data provider for testGetDeleteLink
*
* @return array parameters and output
*/
public function dataProviderForGetDeleteLink()
{
return array(
array(
'sql.php?db=Data&table=customer&sql_query=DELETE+FROM+%60'
. 'Data%60.%60customer%60+WHERE+%60customer%60.%60id%60+%3D+1&'
. 'message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb'
. '%3DData%26table%3Dcustomer%26sql_query%3DSELECT%2B%252A%2BFROM'
. '%2B%2560customer%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen'
. '%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Df597309d3a066c3'
. 'c81a6cb015a79636d&token=f597309d3a066c3c81a6cb015a79636d',
'<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
. 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
'DELETE FROM `Data`.`customer` WHERE `customer`.`id` = 1',
'odd',
'<td class="odd center print_ignore" >' . "\n"
. '<a href="sql.php?db=Data&table=customer&sql_query=DELETE'
. '+FROM+%60Data%60.%60customer%60+WHERE+%60customer%60.%60id%60+%3D'
. '+1&message_to_show=The+row+has+been+deleted&goto=sql.php'
. '%3Fdb%3DData%26table%3Dcustomer%26sql_query%3DSELECT%2B%252A%2B'
. 'FROM%2B%2560customer%2560%26message_to_show%3DThe%2Brow%2Bhas%2B'
. 'been%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Df597309d3a06'
. '6c3c81a6cb015a79636d&token=f597309d3a066c3c81a6cb015a79636d" '
. 'class="delete_row requireConfirm"><span class="nowrap"><img src="themes/dot.'
. 'gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> '
. 'Delete</span></a>' . "\n"
. '<div class="hide">DELETE FROM `Data`.`customer` WHERE '
. '`customer`.`id` = 1</div></td>'
)
);
}
/**
* Test for _getDeleteLink
*
* @param string $del_url delete url
* @param string $del_str text for the delete link
* @param string $js_conf text for the JS confirmation
* @param string $class css classes for the td element
* @param string $output output of _getDeleteLink
*
* @return void
*
* @dataProvider dataProviderForGetDeleteLink
*/
public function testGetDeleteLink(
$del_url, $del_str, $js_conf, $class, $output
) {
$GLOBALS['cfg']['ActionLinksMode'] = 'both';
$GLOBALS['cfg']['LinkLengthLimit'] = 1000;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getDeleteLink',
array(
$del_url, $del_str, $js_conf, $class
)
)
);
}
/**
* Data provider for testGetCheckboxAndLinks
*
* @return array parameters and output
*/
public function dataProviderForGetCheckboxAndLinks()
{
return array(
array(
PMA\libraries\DisplayResults::POSITION_LEFT,
'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data'
. '%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
. 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
. 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26'
. 'message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3D'
. 'tbl_structure.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8'
. '&token=ae4c6d18375f446dfa068420c1f6a4e8',
array(
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
'sort_lnk' => '0',
'nav_bar' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'`new`.`id` = 1',
'%60new%60.%60id%60+%3D+1',
array(
'`new`.`id`' => '= 1',
),
'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
. '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
. 'FROM+%60new%60&goto=sql.php&default_action=update&'
. 'token=ae4c6d18375f446dfa068420c1f6a4e8',
'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
. '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
. 'FROM+%60new%60&goto=sql.php&default_action=insert&'
. 'token=ae4c6d18375f446dfa068420c1f6a4e8',
'edit_row_anchor',
'<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
. 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
. 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
'<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">' . "\n"
. '<a href="tbl_change.php?db=data&table=new&where_'
. 'clause=%60new%60.%60id%60+%3D+1&clause_is_unique=1&'
. 'sql_query=SELECT+%2A+FROM+%60new%60&goto=sql.php&default'
. '_action=update&token=ae4c6d18375f446dfa068420c1f6a4e8" >'
. '<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span></a>' . "\n"
. '<input type="hidden" class="where_clause" value ="%60new%60.%60'
. 'id%60+%3D+1" /></span></td><td class="center print_ignore" ><span class'
. '="nowrap">' . "\n"
. '<a href="tbl_change.php?db=data&table=new&where_clause'
. '=%60new%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
. 'SELECT+%2A+FROM+%60new%60&goto=sql.php&default_action='
. 'insert&token=ae4c6d18375f446dfa068420c1f6a4e8" ><span class'
. '="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" '
. 'class="icon ic_b_insrow" /> Copy</span></a>' . "\n"
. '<input type="hidden" class="where_clause" value="%60new%60.%60id'
. '%60+%3D+1" /></span></td><td class="center print_ignore" >' . "\n"
. '<a href="sql.php?db=data&table=new&sql_query=DELETE+'
. 'FROM+%60data%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&'
. 'message_to_show=The+row+has+been+deleted&goto=sql.php%3F'
. 'db%3Ddata%26table%3Dnew%26sql_query%3DSELECT%2B%252A%2BFROM%2B'
. '%2560new%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2B'
. 'deleted%26goto%3Dtbl_structure.php%26token%3Dae4c6d18375f446d'
. 'fa068420c1f6a4e8&token=ae4c6d18375f446dfa068420c1f6a4e8" '
. 'class="delete_row requireConfirm"><span class="nowrap"><img src="themes/dot.'
. 'gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> '
. 'Delete</span></a>' . "\n"
. '<div class="hide">DELETE FROM `data`.`new` WHERE `new`.`id` = 1'
. '</div></td>'
),
array(
PMA\libraries\DisplayResults::POSITION_RIGHT,
'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60'
. '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
. 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
. 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message'
. '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_'
. 'structure.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8&'
. 'token=ae4c6d18375f446dfa068420c1f6a4e8',
array(
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
'sort_lnk' => '0',
'nav_bar' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'`new`.`id` = 1',
'%60new%60.%60id%60+%3D+1',
array(
'`new`.`id`' => '= 1',
),
'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
. '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
. 'FROM+%60new%60&goto=sql.php&default_action=update&'
. 'token=ae4c6d18375f446dfa068420c1f6a4e8',
'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
. '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
. 'FROM+%60new%60&goto=sql.php&default_action=insert&'
. 'token=ae4c6d18375f446dfa068420c1f6a4e8',
'edit_row_anchor',
'<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
. 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
. 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
'<td class="center print_ignore" >' . "\n"
. '<a href="sql.php?db=data&table=new&sql_query=DELETE+'
. 'FROM+%60data%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&'
. 'message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb'
. '%3Ddata%26table%3Dnew%26sql_query%3DSELECT%2B%252A%2BFROM%2B%25'
. '60new%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted'
. '%26goto%3Dtbl_structure.php%26token%3Dae4c6d18375f446dfa068420c'
. '1f6a4e8&token=ae4c6d18375f446dfa068420c1f6a4e8" class="delete'
. '_row requireConfirm"><span class="nowrap"><img src="themes/dot.gif" title='
. '"Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span></a>'
. "\n" . '<div class="hide">DELETE FROM `data`.`new` WHERE `new`.'
. '`id` = 1</div></td><td class="center print_ignore" ><span class="nowrap">'
. "\n" . '<a href="tbl_change.php?db=data&table=new&where_'
. 'clause=%60new%60.%60id%60+%3D+1&clause_is_unique=1&sql_'
. 'query=SELECT+%2A+FROM+%60new%60&goto=sql.php&default_'
. 'action=insert&token=ae4c6d18375f446dfa068420c1f6a4e8" ><span '
. 'class="nowrap"><img src="themes/dot.gif" title="Copy" alt="Copy" '
. 'class="icon ic_b_insrow" /> Copy</span></a>' . "\n"
. '<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">' . "\n"
. '<a href="tbl_change.php?db=data&table=new&where_clause'
. '=%60new%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
. 'SELECT+%2A+FROM+%60new%60&goto=sql.php&default_action='
. 'update&token=ae4c6d18375f446dfa068420c1f6a4e8" ><span class='
. '"nowrap"><img src="themes/dot.gif" title="Edit" alt="Edit" class'
. '="icon ic_b_edit" /> Edit</span></a>' . "\n"
. '<input type="hidden" class="where_clause" value ="%60new%60.%60'
. 'id%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>'
),
array(
PMA\libraries\DisplayResults::POSITION_NONE,
'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.'
. '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+'
. 'row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3Dnew'
. '%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_'
. 'to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure'
. '.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8&token='
. 'ae4c6d18375f446dfa068420c1f6a4e8',
array(
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
'sort_lnk' => '0',
'nav_bar' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'`new`.`id` = 1',
'%60new%60.%60id%60+%3D+1',
array(
'`new`.`id`' => '= 1',
),
'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
. 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
. '%60new%60&goto=sql.php&default_action=update&token='
. 'ae4c6d18375f446dfa068420c1f6a4e8',
'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
. 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
. '%60new%60&goto=sql.php&default_action=insert&token='
. 'ae4c6d18375f446dfa068420c1f6a4e8',
'edit_row_anchor',
'<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
. 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
. 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
'<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>'
),
);
}
/**
* Test for _getCheckboxAndLinks
*
* @param string $position the position of the checkbox and links
* @param string $del_url delete url
* @param array $displayParts array with explicit indexes for all the
* display elements
* @param string $row_no row number
* @param string $where_clause where clause
* @param string $where_clause_html url encoded where clause
* @param array $condition_array array of conditions in the where clause
* @param string $edit_url edit url
* @param string $copy_url copy url
* @param string $class css classes for the td elements
* @param string $edit_str text for the edit link
* @param string $copy_str text for the copy link
* @param string $del_str text for the delete link
* @param string $js_conf text for the JS confirmation
* @param string $output output of _getCheckboxAndLinks
*
* @return void
*
* @dataProvider dataProviderForGetCheckboxAndLinks
*/
public function testGetCheckboxAndLinks(
$position, $del_url, $displayParts, $row_no, $where_clause,
$where_clause_html, $condition_array, $edit_url,
$copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf, $output
) {
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getCheckboxAndLinks',
array(
$position, $del_url, $displayParts, $row_no, $where_clause,
$where_clause_html, $condition_array,
$edit_url, $copy_url, $class, $edit_str,
$copy_str, $del_str, $js_conf
)
)
);
}
/**
* Data provider for testGetPlacedLinks
*
* @return array parameters and output
*/
public function dataProviderForGetPlacedLinks()
{
return array(
array(
PMA\libraries\DisplayResults::POSITION_NONE,
'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.'
. '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+'
. 'row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3Dnew'
. '%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_'
. 'to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure'
. '.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8&token='
. 'ae4c6d18375f446dfa068420c1f6a4e8',
array(
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
'sort_lnk' => '0',
'nav_bar' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'`new`.`id` = 1',
'%60new%60.%60id%60+%3D+1',
array(
'`new`.`id`' => '= 1',
),
'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
. 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
. '%60new%60&goto=sql.php&default_action=update&token='
. 'ae4c6d18375f446dfa068420c1f6a4e8',
'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60'
. 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+'
. '%60new%60&goto=sql.php&default_action=insert&token='
. 'ae4c6d18375f446dfa068420c1f6a4e8',
'edit_row_anchor',
'<span class="nowrap"><img src="themes/dot.gif" title="Edit" '
. 'alt="Edit" class="icon ic_b_edit" /> Edit</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Copy" '
. 'alt="Copy" class="icon ic_b_insrow" /> Copy</span>',
'<span class="nowrap"><img src="themes/dot.gif" title="Delete" '
. 'alt="Delete" class="icon ic_b_drop" /> Delete</span>',
null,
'<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>'
)
);
}
/**
* Test for _getPlacedLinks
*
* @param string $dir the direction of links should place
* @param string $del_url the url for delete row
* @param array $displayParts which elements to display
* @param integer $row_no the index of current row
* @param string $where_clause the where clause of the sql
* @param string $where_clause_html the html encoded where clause
* @param array $condition_array array of keys (primary, unique, condition)
* @param string $edit_url the url for edit row
* @param string $copy_url the url for copy row
* @param string $edit_anchor_class the class for html element for edit
* @param string $edit_str the label for edit row
* @param string $copy_str the label for copy row
* @param string $del_str the label for delete row
* @param string $js_conf text for the JS confirmation
* @param string $output output of _getPlacedLinks
*
* @return void
*
* @dataProvider dataProviderForGetPlacedLinks
*/
public function testGetPlacedLinks(
$dir, $del_url, $displayParts, $row_no, $where_clause, $where_clause_html,
$condition_array, $edit_url, $copy_url,
$edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf, $output
) {
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getPlacedLinks',
array(
$dir, $del_url, $displayParts, $row_no, $where_clause,
$where_clause_html, $condition_array,
$edit_url, $copy_url, $edit_anchor_class,
$edit_str, $copy_str, $del_str, $js_conf
)
)
);
}
/**
* Data provider for testGetSpecialLinkUrl
*
* @return array parameters and output
*/
public function dataProviderForTestGetSpecialLinkUrl()
{
return array(
array(
'information_schema',
'routines',
'circumference',
array(
'routine_name' => 'circumference',
'routine_schema' => 'data',
'routine_type' => 'FUNCTION'
),
'routine_name',
'db_routines.php?item_name=circumference&db=data'
. '&item_type=FUNCTION&server=0&lang=en'
. '&collation_connection=utf-8'
. '&token=token'
),
array(
'information_schema',
'routines',
'area',
array(
'routine_name' => 'area',
'routine_schema' => 'data',
'routine_type' => 'PROCEDURE'
),
'routine_name',
'db_routines.php?item_name=area&db=data'
. '&item_type=PROCEDURE&server=0&lang=en'
. '&collation_connection=utf-8'
. '&token=token'
),
array(
'information_schema',
'columns',
'CHARACTER_SET_NAME',
array(
'table_schema' => 'information_schema',
'table_name' => 'CHARACTER_SETS'
),
'column_name',
'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60info'
. 'rmation_schema%60.%60CHARACTER_SETS%60&db=information_schema'
. '&test_name=value&server=0&lang=en'
. '&collation_connection=utf-8'
. '&token=token'
)
);
}
/**
* Test _getSpecialLinkUrl
*
* @param string $db the database name
* @param string $table the table name
* @param string $column_value column value
* @param array $row_info information about row
* @param string $field_name column name
* @param boolean $output output of _getSpecialLinkUrl
*
* @return void
*
* @dataProvider dataProviderForTestGetSpecialLinkUrl
*/
public function testGetSpecialLinkUrl(
$db, $table, $column_value, $row_info, $field_name, $output
) {
$GLOBALS['special_schema_links'] = array(
'information_schema' => array(
'routines' => array(
'routine_name' => array(
'link_param' => 'item_name',
'link_dependancy_params' => array(
0 => array(
'param_info' => 'db',
'column_name' => 'routine_schema'
),
1 => array(
'param_info' => 'item_type',
'column_name' => 'routine_type'
)
),
'default_page' => 'db_routines.php'
)
),
'columns' => array(
'column_name' => array(
'link_param' => array(
'sql_query',
'table_schema',
'table_name'
),
'link_dependancy_params' => array(
0 => array(
'param_info' => 'db',
'column_name' => 'table_schema'
),
1 => array(
'param_info' => array('test_name', 'value')
)
),
'default_page' => 'index.php'
)
)
)
);
$this->object->__set('db', $db);
$this->object->__set('table', $table);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getSpecialLinkUrl',
array($column_value, $row_info, $field_name)
)
);
}
/**
* Data provider for testGetRowInfoForSpecialLinks
*
* @return array parameters and output
*/
public function dataProviderForTestGetRowInfoForSpecialLinks()
{
$column_names = array('host', 'db', 'user', 'select_privilages');
$fields_mata = array();
foreach ($column_names as $column_name) {
$field_meta = new stdClass();
$field_meta->name = $column_name;
$fields_mata[] = $field_meta;
}
return array(
array(
$fields_mata,
count($fields_mata),
array(
0 => 'localhost',
1 => 'phpmyadmin',
2 => 'pmauser',
3 => 'Y'
),
array(
0 => '0',
1 => '3',
2 => '1',
3 => '2'
),
array(
'host' => 'localhost',
'select_privilages' => 'Y',
'db' => 'phpmyadmin',
'user' => 'pmauser'
)
)
);
}
/**
* Test _getRowInfoForSpecialLinks
*
* @param array $fields_meta meta information about fields
* @param integer $fields_count number of fields
* @param array $row current row data
* @param array $col_order the column order
* @param boolean $output output of _getRowInfoForSpecialLinks
*
* @return void
*
* @dataProvider dataProviderForTestGetRowInfoForSpecialLinks
*/
public function testGetRowInfoForSpecialLinks(
$fields_meta, $fields_count, $row, $col_order, $output
) {
$this->object->__set('fields_meta', $fields_meta);
$this->object->__set('fields_cnt', $fields_count);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getRowInfoForSpecialLinks',
array($row, $col_order)
)
);
}
/**
* Data provider for testGetShowAllButtonForTableNavigation
*
* @return array parameters and output
*/
public function dataProviderForTestGetShowAllCheckboxForTableNavigation()
{
return array(
array(
'mysql',
'user',
'tbl_structure.php',
0,
'SELECT * FROM `user`',
"\n"
. '<td><form action="sql.php" method="post">'
. '<input type="hidden" name="db" value="mysql" />'
. '<input type="hidden" name="table" value="user" />'
. '<input type="hidden" name="lang" value="en" />'
. '<input type="hidden" name="collation_connection" value="utf-8" />'
. '<input type="hidden" name="token" value="token" />'
. '<input type="hidden" name="sql_query" value="SELECT * FROM `user`" />'
. '<input type="hidden" name="pos" value="0" />'
. '<input type="hidden" name="is_browse_distinct" value="" />'
. '<input type="hidden" name="session_max_rows" value="all" />'
. '<input type="hidden" name="goto" value="tbl_structure.php" />'
. '<input type="checkbox" name="navig" id="showAll_0"'
. ' class="showAllRows" value="all" />'
. '<label for="showAll_0">Show all</label></form></td>'
)
);
}
/**
* Test _getShowAllButtonForTableNavigation
*
* @param string $db the database name
* @param string $table the table name
* @param string $goto the URL to go back in case of errors
* @param int $unique_id the unique id for the results set
* @param string $html_sql_query the sql encoded by html special characters
* @param string $output output of _getRowInfoForSpecialLinks
*
* @return void
*
* @dataProvider dataProviderForTestGetShowAllCheckboxForTableNavigation
*/
public function testGetShowAllCheckboxForTableNavigation(
$db, $table, $goto, $unique_id , $html_sql_query, $output
) {
$this->object->__set('db', $db);
$this->object->__set('table', $table);
$this->object->__set('goto', $goto);
$this->object->__set('unique_id', $unique_id);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getShowAllCheckboxForTableNavigation',
array(false, $html_sql_query)
)
);
}
/**
* Data provider for testSetHighlightedColumnGlobalField
*
* @return array parameters and output
*/
public function dataProviderForTestSetHighlightedColumnGlobalField()
{
$parser = new SqlParser\Parser(
'SELECT * FROM db_name WHERE `db_name`.`tbl`.id > 0 AND `id` < 10'
);
return array(
array(
array('statement' => $parser->statements[0]),
array(
'db_name' => 'true',
'tbl' => 'true',
'id' => 'true',
),
),
);
}
/**
* Test _setHighlightedColumnGlobalField
*
* @param array $analyzed_sql the analyzed query
* @param array $output setting value of _setHighlightedColumnGlobalField
*
* @return void
*
* @dataProvider dataProviderForTestSetHighlightedColumnGlobalField
*/
public function testSetHighlightedColumnGlobalField($analyzed_sql, $output)
{
$this->_callPrivateFunction(
'_setHighlightedColumnGlobalField',
array($analyzed_sql)
);
$this->assertEquals(
$output,
$this->object->__get('highlight_columns')
);
}
/**
* Data provider for testGetPartialText
*
* @return array parameters and output
*/
public function dataProviderForTestGetPartialText()
{
return array(
array('P', 10, 'foo', array(false, 'foo', 3)),
array('P', 1, 'foo', array(true, 'f...', 3)),
array('F', 10, 'foo', array(false, 'foo', 3)),
array('F', 1, 'foo', array(false, 'foo', 3))
);
}
/**
* Test _getPartialText
*
* @param string $pftext Partial or Full text
* @param integer $limitChars Partial or Full text
* @param string $str the string to be tested
* @param boolean $output return value of _getPartialText
*
* @return void
*
* @dataProvider dataProviderForTestGetPartialText
*/
public function testGetPartialText($pftext, $limitChars, $str, $output)
{
$_SESSION['tmpval']['pftext'] = $pftext;
$GLOBALS['cfg']['LimitChars'] = $limitChars;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getPartialText',
array($str)
)
);
}
/**
* Data provider for testHandleNonPrintableContents
*
* @return array parameters and output
*/
public function dataProviderForTestHandleNonPrintableContents()
{
$transformation_plugin = new Text_Plain_Link();
$meta = new StdClass();
$meta->type = 'BLOB';
$meta->orgtable = 'bar';
$url_params = array('db' => 'foo', 'table' => 'bar', 'where_clause' => 'where_clause');
return array(
array(
true,
true,
'BLOB',
'1001',
'PMA_mimeDefaultFunction',
'',
'PMA_mimeDefaultFunction',
$meta,
$url_params,
null,
'class="disableAjax">1001</a>'
),
array(
true,
true,
'BLOB',
hex2bin('123456'),
'PMA_mimeDefaultFunction',
'',
'PMA_mimeDefaultFunction',
$meta,
$url_params,
null,
'class="disableAjax">0x123456</a>'
),
array(
true,
false,
'BLOB',
'1001',
'PMA_mimeDefaultFunction',
'',
'PMA_mimeDefaultFunction',
$meta,
$url_params,
null,
'class="disableAjax">[BLOB - 4 B]</a>'
),
array(
false,
false,
'BINARY',
'1001',
$transformation_plugin,
'',
'PMA_mimeDefaultFunction',
$meta,
$url_params,
null,
'1001'
),
array(
false,
true,
'GEOMETRY',
null,
'',
'',
'PMA_mimeDefaultFunction',
$meta,
$url_params,
null,
'[GEOMETRY - NULL]'
)
);
}
/**
* Test _handleNonPrintableContents
*
* @param boolean $display_binary show binary contents?
* @param boolean $display_blob show blob contents?
* @param string $category BLOB|BINARY|GEOMETRY
* @param string $content the binary content
* @param string $transformation_plugin transformation plugin.
* Can also be the default function:
* PMA_mimeDefaultFunction
* @param string $transform_options transformation parameters
* @param string $default_function default transformation function
* @param object $meta the meta-information about the field
* @param array $url_params parameters that should go to the
* download link
* @param boolean $is_truncated the result is truncated or not
* @param string $output the output of this function
*
* @return void
*
* @dataProvider dataProviderForTestHandleNonPrintableContents
*/
public function testHandleNonPrintableContents(
$display_binary, $display_blob, $category, $content,
$transformation_plugin, $transform_options, $default_function,
$meta, $url_params, $is_truncated, $output
) {
$_SESSION['tmpval']['display_binary'] = $display_binary;
$_SESSION['tmpval']['display_blob'] = $display_blob;
$GLOBALS['cfg']['LimitChars'] = 50;
$this->assertContains(
$output,
$this->_callPrivateFunction(
'_handleNonPrintableContents',
array(
$category, $content, $transformation_plugin,
$transform_options, $default_function,
$meta, $url_params, &$is_truncated
)
)
);
}
/**
* Data provider for testGetDataCellForNonNumericColumns
*
* @return array parameters and output
*/
public function dataProviderForTestGetDataCellForNonNumericColumns()
{
$transformation_plugin = new Text_Plain_Link();
$meta = new StdClass();
$meta->db = 'foo';
$meta->table = 'tbl';
$meta->orgtable = 'tbl';
$meta->type = 'BLOB';
$meta->flags = 'blob binary';
$meta->name = 'tblob';
$meta->orgname = 'tblob';
$meta2 = new StdClass();
$meta2->db = 'foo';
$meta2->table = 'tbl';
$meta2->orgtable = 'tbl';
$meta2->type = 'string';
$meta2->flags = '';
$meta2->decimals = 0;
$meta2->name = 'varchar';
$meta2->orgname = 'varchar';
$url_params = array('db' => 'foo', 'table' => 'tbl', 'where_clause' => 'where_clause');
return array(
array(
'all',
'1001',
'grid_edit',
$meta,
array(),
$url_params,
false,
'PMA_mimeDefaultFunction',
'PMA_mimeDefaultFunction',
array('https://www.example.com/'),
false,
array(),
0,
'binary',
'class="disableAjax">[BLOB - 4 B]</a>'
),
array(
'noblob',
'1001',
'grid_edit',
$meta,
array(),
$url_params,
false,
$transformation_plugin,
'PMA_mimeDefaultFunction',
'',
false,
array(),
0,
'binary',
'<td class="left grid_edit transformed hex">'
. '1001</td>'
),
array(
'noblob',
null,
'grid_edit',
$meta2,
array(),
$url_params,
false,
$transformation_plugin,
'PMA_mimeDefaultFunction',
'',
false,
array(),
0,
0,
'<td data-decimals="0" data-type="string" '
. 'class="grid_edit null"><i>NULL</i></td>'
),
array(
'all',
'foo bar baz',
'grid_edit',
$meta2,
array(),
$url_params,
false,
'PMA_mimeDefaultFunction',
'PMA_mimeDefaultFunction',
'',
false,
array(),
0,
0,
'<td data-decimals="0" data-type="string" '
. 'data-originallength="11" '
. 'class="grid_edit ">foo bar baz</td>' . "\n"
)
);
}
/**
* Test _getDataCellForNonNumericColumns
*
* @param boolean $protectBinary all|blob|noblob|no
* @param string $column the relevant column in data row
* @param string $class the html class for column
* @param object $meta the meta-information about the field
* @param array $map the list of relations
* @param array $_url_params the parameters for generate url
* @param boolean $condition_field the column should highlighted
* or not
* @param string $transformation_plugin the name of transformation function
* @param string $default_function the default transformation function
* @param string $transform_options the transformation parameters
* @param boolean $is_field_truncated is data truncated due to LimitChars
* @param array $analyzed_sql_results the analyzed query
* @param integer $dt_result the link id associated to the query
* which results have to be displayed
* @param integer $col_index the column index
* @param string $output the output of this function
*
* @return void
*
* @dataProvider dataProviderForTestGetDataCellForNonNumericColumns
*/
public function testGetDataCellForNonNumericColumns(
$protectBinary, $column, $class, $meta, $map,
$_url_params, $condition_field, $transformation_plugin,
$default_function, $transform_options, $is_field_truncated,
$analyzed_sql_results, $dt_result, $col_index, $output
) {
$_SESSION['tmpval']['display_binary'] = true;
$_SESSION['tmpval']['display_blob'] = false;
$_SESSION['tmpval']['relational_display'] = false;
$GLOBALS['cfg']['LimitChars'] = 50;
$GLOBALS['cfg']['ProtectBinary'] = $protectBinary;
$this->assertContains(
$output,
$this->_callPrivateFunction(
'_getDataCellForNonNumericColumns',
array(
$column, $class, $meta, $map, $_url_params, $condition_field,
$transformation_plugin, $default_function, $transform_options,
$is_field_truncated, $analyzed_sql_results, &$dt_result, $col_index
)
)
);
}
}
|