-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
PMA_DisplayResults_test.php
1648 lines (1553 loc) · 67.2 KB
/
PMA_DisplayResults_test.php
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
<?php
/**
* Tests for displaing results
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/DisplayResults.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Util.class.php';
require_once 'libraries/js_escape.lib.php';
require_once 'libraries/core.lib.php';
require_once 'libraries/Config.class.php';
/**
* Test cases for displaying results.
*
* @package PhpMyAdmin-test
*/
class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase
{
/**
* @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()
{
$this->object = new PMA_DisplayResults('as', '', '', '');
$GLOBALS['PMA_Config'] = new PMA_Config();
$GLOBALS['PMA_Config']->enableBc();
$_SESSION[' PMA_token '] = 'token';
$GLOBALS['lang'] = 'en';
$GLOBALS['server'] = 0;
$GLOBALS['text_dir'] = 'ltr';
include_once 'libraries/Response.class.php';
}
/**
* 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_DisplayResults');
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($this->object, $params);
}
/**
* Test for setting display mode
*
* @param string $the_disp_mode the synthetic value for display_mode (see
* a few lines above for explanations)
* @param integer $the_total the total number of rows returned by the SQL
* query without any programmatically appended
* LIMIT clause
* (just a copy of $unlim_num_rows if it exists,
* elsecomputed inside this function)
* @param string $output output from the _setDisplayMode method
*
* @return void
*
* @dataProvider providerForTestSetDisplayModeCase1
*/
public function testSetDisplayModeCase1($the_disp_mode, $the_total, $output)
{
if (!isset($GLOBALS['fields_meta'])) {
$fields_meta = array();
$fields_meta[0] = new stdClass();
$fields_meta[0]->table = 'company';
} else {
$fields_meta = $GLOBALS['fields_meta'];
}
$this->object->setProperties(
null, $fields_meta, true, null, null,
null, null, null, null, null, null,
true, null, null, null, null, null, false
);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_setDisplayMode',
array(&$the_disp_mode, &$the_total)
)
);
}
/**
* Provider for testSetDisplayModeCase1
*
* @return array data for testSetDisplayModeCase1
*/
public function providerForTestSetDisplayModeCase1()
{
return array(
array(
'urkp111111',
5,
array(
'edit_lnk' => 'nn',
'del_lnk' => 'nn',
'sort_lnk' => 0,
'nav_bar' => 0,
'ins_row' => 0,
'bkm_form' => 1,
'text_btn' => 1,
'pview_lnk' => 1
)
),
array(
'nnnn000000',
5,
array(
'edit_lnk' => 'nn',
'del_lnk' => 'nn',
'sort_lnk' => 0,
'nav_bar' => 0,
'ins_row' => 0,
'bkm_form' => 0,
'text_btn' => 0,
'pview_lnk' => 0
)
)
);
}
/**
* Test for setting display mode
*
* @param string $the_disp_mode the synthetic value for display_mode (see a
* few lines above for explanations)
* @param integer $the_total the total number of rows returned by the SQL
* query without any programmatically appended
* LIMIT clause
* (just a copy of $unlim_num_rows if it exists,
* elsecomputed inside this function)
* @param string $output output from the _setDisplayMode method
*
* @return void
*
* @dataProvider providerForTestSetDisplayModeCase2
*/
public function testSetDisplayModeCase2($the_disp_mode, $the_total, $output)
{
if (!isset($GLOBALS['fields_meta'])) {
$fields_meta = array();
$fields_meta[0] = new stdClass();
$fields_meta[0]->table = 'company';
} else {
$fields_meta = $GLOBALS['fields_meta'];
}
$this->object->setProperties(
1, $fields_meta, false, null, null,
false, null, null, null, null, null,
false, false, true, null, null, null, false
);
$this->object->__set('sql_query', 'SELECT * FROM `pma_bookmark` WHERE 1');
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_setDisplayMode',
array(&$the_disp_mode, &$the_total)
)
);
}
/**
* Provider for testSetDisplayModeCase2
*
* @return array data for testSetDisplayModeCase2
*/
public function providerForTestSetDisplayModeCase2()
{
return array(
array(
'urkp111111',
5,
array(
'edit_lnk' => 'nn',
'del_lnk' => 'nn',
'sort_lnk' => 0,
'nav_bar' => 0,
'ins_row' => 0,
'bkm_form' => 1,
'text_btn' => 1,
'pview_lnk' => 1
)
),
array(
'nnnn000000',
5,
array(
'edit_lnk' => 'nn',
'del_lnk' => 'nn',
'sort_lnk' => 0,
'nav_bar' => 0,
'ins_row' => 0,
'bkm_form' => 0,
'text_btn' => 0,
'pview_lnk' => 0
)
)
);
}
/**
* Test for setting display mode
*
* @param string $the_disp_mode the synthetic value for display_mode (see a
* few lines above for explanations)
* @param integer $the_total the total number of rows returned by the SQL
* query without any programmatically appended
* LIMIT clause
* (just a copy of $unlim_num_rows if it exists,
* elsecomputed inside this function)
* @param string $output output from the _setDisplayMode method
*
* @return void
*
* @dataProvider providerForTestSetDisplayModeCase3
*/
public function testSetDisplayModeCase3($the_disp_mode, $the_total, $output)
{
if (!isset($GLOBALS['fields_meta'])) {
$fields_meta = array();
$fields_meta[0] = new stdClass();
$fields_meta[0]->table = 'company';
} else {
$fields_meta = $GLOBALS['fields_meta'];
}
$this->object->setProperties(
1, $fields_meta, false, null, null,
false, null, null, null, null, null,
false, false, null, null, '1', null, false
);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_setDisplayMode',
array(&$the_disp_mode, &$the_total)
)
);
}
/**
* Provider for testSetDisplayModeCase3
*
* @return array data for testSetDisplayModeCase3
*/
public function providerForTestSetDisplayModeCase3()
{
return array(
array(
'urkp111111',
5,
array(
'edit_lnk' => 'nn',
'del_lnk' => 'nn',
'sort_lnk' => 0,
'nav_bar' => 0,
'ins_row' => 0,
'bkm_form' => 0,
'text_btn' => 0,
'pview_lnk' => 0
)
),
array(
'nnnn000000',
5,
array(
'edit_lnk' => 'nn',
'del_lnk' => 'nn',
'sort_lnk' => 0,
'nav_bar' => 0,
'ins_row' => 0,
'bkm_form' => 0,
'text_btn' => 0,
'pview_lnk' => 0
)
)
);
}
/**
* Test for _isSelect function
*
* @return void
*/
public function testisSelect()
{
$analyzed_sql[0]['select_expr'] = array();
$analyzed_sql[0]['queryflags']['select_from'] = 'pma';
$analyzed_sql[0]['table_ref'] = array('table_ref');
$this->assertTrue(
$this->_callPrivateFunction(
'_isSelect',
array($analyzed_sql)
)
);
}
/**
* 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']['NavigationBarIconic'] = true;
$_SESSION[' PMA_token '] = 'token';
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getTableNavigationButton',
array(&$caption, $title, $pos, $html_sql_query)
)
);
}
/**
* 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="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="goto" value="" />'
. '<input type="submit" name="navig" class="ajax" '
. 'value="btn" title="Submit" /></form></td>'
)
);
}
/**
* Test for table navigation
*
* @param integer $pos_next the offset for the "next" page
* @param integer $pos_prev the offset for the "previous" page
* @param string $id_for_direction_dropdown the id for the direction dropdown
* @param boolean $is_innodb the table type is innoDb or not
* @param string $output output from the _getTableNavigation
* method
*
* @return void
*
* @dataProvider providerForTestGetTableNavigation
*/
public function testGetTableNavigation(
$pos_next, $pos_prev, $id_for_direction_dropdown, $is_innodb, $output
) {
$_SESSION['tmp_user_values']['max_rows'] = '20';
$_SESSION['tmp_user_values']['pos'] = true;
$GLOBALS['num_rows'] = '20';
$GLOBALS['unlim_num_rows'] = '50';
$GLOBALS['cfg']['ShowAll'] = true;
$GLOBALS['cfg']['ShowDisplayDirection'] = true;
$_SESSION['tmp_user_values']['repeat_cells'] = '1';
$_SESSION['tmp_user_values']['disp_direction'] = '1';
$this->assertEquals(
$output,
str_word_count(
$this->_callPrivateFunction(
'_getTableNavigation',
array(
$pos_next, $pos_prev, $id_for_direction_dropdown, $is_innodb
)
)
)
);
}
/**
* Provider for testing table navigation
*
* @return array data for testGetTableNavigation
*/
public function providerForTestGetTableNavigation()
{
return array(
array(
21,
41,
'123',
false,
'330'
)
);
}
/**
* Data provider for testGetClassesForColumn
*
* @return array parameters and output
*/
public function dataProviderForTestGetClassesForColumn()
{
return array(
array(
'grid_edit',
'not_null',
'',
'',
'',
0,
'data grid_edit not_null row_0 vpointer vmarker'
)
);
}
/**
* 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 integer $row_no the row index
* @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, $row_no, $output
) {
$GLOBALS['cfg']['BrowsePointerEnable'] = true;
$GLOBALS['cfg']['BrowseMarkerEnable'] = true;
$_SESSION['tmp_user_values']['disp_direction']
= PMA_DisplayResults::DISP_DIR_VERTICAL;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getClassesForColumn',
array(
$grid_edit_class, $not_null_class, $relation_class,
$hide_class, $field_type_class, $row_no
)
)
);
}
/**
* Test for _getClassForDateTimeRelatedFields - case 1
*
* @return void
*/
public function testGetClassForDateTimeRelatedFieldsCase1()
{
$this->assertEquals(
'datetimefield',
$this->_callPrivateFunction(
'_getClassForDateTimeRelatedFields',
array(PMA_DisplayResults::DATETIME_FIELD)
)
);
}
/**
* Test for _getClassForDateTimeRelatedFields - case 2
*
* @return void
*/
public function testGetClassForDateTimeRelatedFieldsCase2()
{
$this->assertEquals(
'datefield',
$this->_callPrivateFunction(
'_getClassForDateTimeRelatedFields',
array(PMA_DisplayResults::DATE_FIELD)
)
);
}
/**
* Test for _getClassForDateTimeRelatedFields - case 3
*
* @return void
*/
public function testGetClassForDateTimeRelatedFieldsCase3()
{
$this->assertEquals(
'',
$this->_callPrivateFunction(
'_getClassForDateTimeRelatedFields',
array(PMA_DisplayResults::STRING_FIELD)
)
);
}
/**
* Provide data for testGetOperationLinksForVerticleTable
*
* @return array parameters and output
*/
public function dataProviderForTestGetOperationLinksForVerticleTable()
{
return array(
array(
'edit',
'<tr>
</tr>
'
),
array(
'copy',
'<tr>
<td class="odd row_0 vpointer vmarker center" ><span class="nowrap">\n<a href="tbl_change.php?db=Data&table=cars&where_clause=%60cars%60.%60id%60+%3D+3&clause_is_unique=1&sql_query=SELECT+%2A+FROM+%60cars%60&goto=sql.php&default_action=insert&token=466f137b5f4556e43103245a086fc001" ><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="%60cars%60.%60id%60+%3D+3" /></spa<td class="even row_1 vpointer vmarker center" ><span class="nowrap">\n<a href="tbl_change.php?db=Data&table=cars&where_clause=%60cars%60.%60id%60+%3D+9&clause_is_unique=1&sql_query=SELECT+%2A+FROM+%60cars%60&goto=sql.php&default_action=insert&token=466f137b5f4556e43103245a086fc001" ><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="%60cars%60.%60id%60+%3D+9" /></sp</tr>
'
),
array(
'delete',
'<tr>
<td class="odd row_0 vpointer vmarker center" >\n<a href="sql.php?db=Data&table=cars&sql_query=DELETE+FROM+%60Data%60.%60cars%60+WHERE+%60cars%60.%60id%60+%3D+3&message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb%3DData%26table%3Dcars%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560cars%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3D466f137b5f4556e43103245a086fc001&token=466f137b5f4556e43103245a086fc001" onclick="return confirmLink(this,<td class="even row_1 vpointer vmarker center" >\n<a href="sql.php?db=Data&table=cars&sql_query=DELETE+FROM+%60Data%60.%60cars%60+WHERE+%60cars%60.%60id%60+%3D+9&message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb%3DData%26table%3Dcars%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560cars%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3D466f137b5f4556e43103245a086fc001&token=466f137b5f4556e43103245a086fc001" onclick="return confirmLink(this</tr>
'
),
);
}
/**
* Test for _getOperationLinksForVerticleTable
*
* @param string $operation edit/copy/delete
* @param string $output output of _getOperationLinksForVerticleTable
*
* @return void
*
* @dataProvider dataProviderForTestGetOperationLinksForVerticleTable
*/
public function testGetOperationLinksForVerticleTable(
$operation, $output
) {
$vertical_display = array(
'row_delete' => array(),
'textbtn' => '<th rowspan="4" class="vmiddle">\n \n </th>\n',
'edit' => array(),
'copy' => array(
'<td class="odd row_0 vpointer vmarker center" ><span class="nowrap">\n<a href="tbl_change.php?db=Data&table=cars&where_clause=%60cars%60.%60id%60+%3D+3&clause_is_unique=1&sql_query=SELECT+%2A+FROM+%60cars%60&goto=sql.php&default_action=insert&token=466f137b5f4556e43103245a086fc001" ><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="%60cars%60.%60id%60+%3D+3" /></spa',
'<td class="even row_1 vpointer vmarker center" ><span class="nowrap">\n<a href="tbl_change.php?db=Data&table=cars&where_clause=%60cars%60.%60id%60+%3D+9&clause_is_unique=1&sql_query=SELECT+%2A+FROM+%60cars%60&goto=sql.php&default_action=insert&token=466f137b5f4556e43103245a086fc001" ><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="%60cars%60.%60id%60+%3D+9" /></sp'
),
'delete' => array(
'<td class="odd row_0 vpointer vmarker center" >\n<a href="sql.php?db=Data&table=cars&sql_query=DELETE+FROM+%60Data%60.%60cars%60+WHERE+%60cars%60.%60id%60+%3D+3&message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb%3DData%26table%3Dcars%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560cars%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3D466f137b5f4556e43103245a086fc001&token=466f137b5f4556e43103245a086fc001" onclick="return confirmLink(this,',
'<td class="even row_1 vpointer vmarker center" >\n<a href="sql.php?db=Data&table=cars&sql_query=DELETE+FROM+%60Data%60.%60cars%60+WHERE+%60cars%60.%60id%60+%3D+9&message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb%3DData%26table%3Dcars%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560cars%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3D466f137b5f4556e43103245a086fc001&token=466f137b5f4556e43103245a086fc001" onclick="return confirmLink(this'
)
);
$this->object->__set('vertical_display', $vertical_display);
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getOperationLinksForVerticleTable',
array($operation)
)
);
}
/**
* Data provider for testGetCheckBoxesForMultipleRowOperations
*
* @return array parameters and output
*/
public function dataProviderForGetCheckBoxesForMultipleRowOperations()
{
return array(
array(
'_left',
'<td class="odd row_0 vpointer vmarker" class="center"><input type="checkbox" id="id_rows_to_delete0_left" name="rows_to_delete[0]" class="multi_checkbox" value="%60cars%60.%60id%60+%3D+3" /><input type="hidden" class="condition_array" value="{"`cars`.`id`":"= 3"}" /> </td><td class="even row_1 vpointer vmarker" class="center"><input type="checkbox" id="id_rows_to_delete1_left" name="rows_to_delete[1]" class="multi_checkbox" value="%60cars%60.%60id%60+%3D+9" /><input type="hidden" class="condition_array" value="{"`cars`.`id`":"= 9"}" /> </td>'
)
);
}
/**
* Test for _getCheckBoxesForMultipleRowOperations
*
* @param string $dir _left / _right
* @param string $output output of _getCheckBoxesForMultipleRowOperations
*
* @return void
*
* @dataProvider dataProviderForGetCheckBoxesForMultipleRowOperations
*/
public function testGetCheckBoxesForMultipleRowOperations(
$dir, $output
) {
$vertical_display = array(
'row_delete' => array(
'<td class="odd row_0 vpointer vmarker" class="center"><input type="checkbox" id="id_rows_to_delete0[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[0]" class="multi_checkbox" value="%60cars%60.%60id%60+%3D+3" /><input type="hidden" class="condition_array" value="{"`cars`.`id`":"= 3"}" /> </td>',
'<td class="even row_1 vpointer vmarker" class="center"><input type="checkbox" id="id_rows_to_delete1[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[1]" class="multi_checkbox" value="%60cars%60.%60id%60+%3D+9" /><input type="hidden" class="condition_array" value="{"`cars`.`id`":"= 9"}" /> </td>'
)
);
$this->object->__set('vertical_display', $vertical_display);
$_SESSION['tmp_user_values']['repeat_cells'] = 0;
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getCheckBoxesForMultipleRowOperations',
array($dir)
)
);
}
/**
* Test for _getOffsets - case 1
*
* @return void
*/
public function testGetOffsetsCase1()
{
$_SESSION['tmp_user_values']['max_rows'] = PMA_DisplayResults::ALL_ROWS;
$this->assertEquals(
array(0, 0),
$this->_callPrivateFunction('_getOffsets', array())
);
}
/**
* Test for _getOffsets - case 2
*
* @return void
*/
public function testGetOffsetsCase2()
{
$_SESSION['tmp_user_values']['max_rows'] = 5;
$_SESSION['tmp_user_values']['pos'] = 4;
$this->assertEquals(
array(9, 0),
$this->_callPrivateFunction('_getOffsets', array())
);
}
/**
* Data provider for testGetSortParams
*
* @return array parameters and output
*/
public function dataProviderForGetSortParams()
{
return array(
array('', array('', '', '')),
array(
'`a_sales`.`customer_id` ASC',
array(
'`a_sales`.`customer_id` ASC',
'`a_sales`.`customer_id`',
'ASC'
)
),
);
}
/**
* Test for _getSortParams
*
* @param string $order_by_clause the order by clause of the sql query
* @param string $output output of _getSortParams
*
* @return void
*
* @dataProvider dataProviderForGetSortParams
*/
public function testGetSortParams($order_by_clause, $output)
{
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getSortParams', array($order_by_clause)
)
);
}
/**
* 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%3Dnew%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',
'ins_row' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'%60new%60.%60id%60+%3D+1',
array('`new`.`id`' => '= 1'),
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
'[%_PMA_CHECKBOX_DIR_%]',
'odd row_0 vpointer vmarker',
'<td class="odd row_0 vpointer vmarker" class="center"><input type="checkbox" id="id_rows_to_delete0[%_PMA_CHECKBOX_DIR_%]" 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 _getCheckboxForMultiRowSubmissions
*
* @param string $del_url delete url
* @param array $is_display 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 $del_query delete query
* @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, $is_display, $row_no, $where_clause_html, $condition_array,
$del_query, $id_suffix, $class, $output
) {
$this->assertEquals(
$output,
$this->_callPrivateFunction(
'_getCheckboxForMultiRowSubmissions',
array(
$del_url, $is_display, $row_no, $where_clause_html,
$condition_array, $del_query, $id_suffix, $class
)
)
);
}
/**
* Data provider for testGetEditLink
*
* @return array parametres and output
*/
public function dataProviderForGetEditLink()
{
return array(
array(
'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',
'odd edit_row_anchor row_0 vpointer vmarker',
'<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 row_0 vpointer vmarker center" ><span class="nowrap">
<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>
<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']['PropertiesIconic'] = '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=%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>',
'`customer`.`id` = 1',
'%60customer%60.%60id%60+%3D+1',
'odd row_0 vpointer vmarker',
'<td class="odd row_0 vpointer vmarker center" ><span class="nowrap">
<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>
<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']['PropertiesIconic'] = '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+%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%2BFROM%2B%2560customer%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Df597309d3a066c3c81a6cb015a79636d&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 row_0 vpointer vmarker',
'<td class="odd row_0 vpointer vmarker center" >
<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%2BFROM%2B%2560customer%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Df597309d3a066c3c81a6cb015a79636d&token=f597309d3a066c3c81a6cb015a79636d" class="delete_row"><span class="nowrap"><img src="themes/dot.gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span></a>
<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']['PropertiesIconic'] = '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_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%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',
'ins_row' => '1',
'bkm_form' => '1',
'text_btn' => '1',
'pview_lnk' => '1'
),
0,
'`new`.`id` = 1',
'%60new%60.%60id%60+%3D+1',
array(
'`new`.`id`' => '= 1',
),
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
'l',
'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"><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" ><span class="nowrap">
<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>
<input type="hidden" class="where_clause" value ="%60new%60.%60id%60+%3D+1" /></span></td><td class="center" ><span class="nowrap">
<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>
<input type="hidden" class="where_clause" value="%60new%60.%60id%60+%3D+1" /></span></td><td class="center" >
<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%2560new%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8&token=ae4c6d18375f446dfa068420c1f6a4e8" class="delete_row"><span class="nowrap"><img src="themes/dot.gif" title="Delete" alt="Delete" class="icon ic_b_drop" /> Delete</span></a>
<div class="hide">DELETE FROM `data`.`new` WHERE `new`.`id` = 1</div></td>'