sortable_table.class.test.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php';
  3. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  4. class TestSortableTable extends UnitTestCase {
  5. public function __construct() {
  6. $this->UnitTestCase('Sortabletable library - main/inc/lib/sortable_table.class.test.php');
  7. }
  8. function testdisplay() {
  9. $instancia = new SortableTable();
  10. global $charset;
  11. ob_start();
  12. $res=$instancia->display();
  13. $this->assertTrue(is_null($res));
  14. ob_end_clean();
  15. //var_dump($res);
  16. }
  17. function testfilter_data() {
  18. $instancia = new SortableTable();
  19. $row=array();
  20. $res=$instancia->filter_data($row);
  21. $this->assertTrue(is_array($res));
  22. //var_dump($res);
  23. }
  24. function testget_additional_url_paramstring() {
  25. $instancia = new SortableTable();
  26. $res=$instancia->get_additional_url_paramstring();
  27. $this->assertTrue(is_string($res));
  28. //var_dump($res);
  29. }
  30. function testget_navigation_html() {
  31. $instancia = new SortableTable();
  32. $res=$instancia->get_navigation_html();
  33. $this->assertTrue(is_string($res));
  34. //var_dump($res);
  35. }
  36. function testget_page_select_form() {
  37. $instancia = new SortableTable();
  38. $res=$instancia->get_page_select_form();
  39. $this->assertTrue(is_string($res));
  40. //var_dump($res);
  41. }
  42. function testget_pager() {
  43. $instancia = new SortableTable();
  44. $res=$instancia->get_pager();
  45. $this->assertTrue(is_object($res));
  46. //var_dump($res);
  47. }
  48. function testget_sortable_table_param_string() {
  49. $instancia = new SortableTable();
  50. $res=$instancia->get_sortable_table_param_string();
  51. $this->assertTrue(is_string($res));
  52. //var_dump($res);
  53. }
  54. function testget_table_data() {
  55. $instancia = new SortableTable();
  56. $res=$instancia->get_table_data();
  57. $this->assertTrue(is_array($res));
  58. //var_dump($res);
  59. }
  60. function testget_table_html() {
  61. $instancia = new SortableTable();
  62. $res=$instancia->get_table_html();
  63. $this->assertTrue(is_string($res));
  64. //var_dump($res);
  65. }
  66. function testget_table_title() {
  67. $instancia = new SortableTable();
  68. $res=$instancia->get_table_title();
  69. $this->assertTrue(is_string($res));
  70. //var_dump($res);
  71. }
  72. function testget_total_number_of_items() {
  73. $instancia = new SortableTable();
  74. $res=$instancia->get_total_number_of_items();
  75. $this->assertTrue(is_numeric($res));
  76. //var_dump($res);
  77. }
  78. function testset_additional_parameters() {
  79. $instancia = new SortableTable();
  80. $parameters='';
  81. $res=$instancia->set_additional_parameters($parameters);
  82. $this->assertTrue(is_null($res));
  83. //var_dump($res);
  84. }
  85. function testset_column_filter() {
  86. $instancia = new SortableTable();
  87. $column='';
  88. $function='';
  89. $res=$instancia->set_column_filter($column, $function);
  90. $this->assertTrue(is_null($res));
  91. //var_dump($res);
  92. }
  93. function testset_form_actions() {
  94. $instancia = new SortableTable();
  95. $actions='';
  96. $checkbox_name = 'id';
  97. $res=$instancia->set_form_actions($actions, $checkbox_name = 'id');
  98. $this->assertTrue(is_null($res));
  99. //var_dump($res);
  100. }
  101. function testset_header() {
  102. $instancia = new SortableTable();
  103. $column='';
  104. $label='';
  105. $res=$instancia->set_header($column, $label, $sortable = true, $th_attributes = null, $td_attributes = null);
  106. $this->assertTrue(is_null($res));
  107. //var_dump($res);
  108. }
  109. function testset_other_tables() {
  110. $instancia = new SortableTable();
  111. $tablenames='';
  112. $res=$instancia->set_other_tables($tablenames);
  113. $this->assertTrue(is_null($res));
  114. //var_dump($res);
  115. }
  116. }
  117. class TestSortableTableFromArray extends UnitTestCase {
  118. function testget_table_data() {
  119. $res=SortableTableFromArray::get_table_data($from=1);
  120. $this->assertTrue(is_array($res));
  121. //var_dump($res);
  122. }
  123. function testget_total_number_of_items() {
  124. $res=SortableTableFromArray::get_total_number_of_items();
  125. $this->assertTrue(is_numeric($res));
  126. //var_dump($res);
  127. }
  128. }
  129. class TestSortableTableFromArrayConfig extends UnitTestCase {
  130. public function testget_table_data() {
  131. $res=SortableTableFromArray::get_table_data($from=1);
  132. $this->assertTrue(is_array($res));
  133. //var_dump($res);
  134. }
  135. public function testget_total_number_of_items() {
  136. $res=SortableTableFromArray::get_total_number_of_items();
  137. $this->assertTrue(is_numeric($res));
  138. //var_dump($res);
  139. }
  140. }
  141. ?>