tablesort.lib.test.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. define('SORT_DATE', 3);
  3. define('SORT_IMAGE',4);
  4. class TestTablesort extends UnitTestCase{
  5. //public $table;
  6. public function __construct(){
  7. $this->UnitTestCase('Tablesort library - main/inc/lib/tablesort.lib.test.php');
  8. }
  9. /*
  10. public function setUp(){
  11. $this->table = new TableSort();
  12. }
  13. public function tearDown(){
  14. $this->table = null;
  15. }
  16. */
  17. public function testSortTable(){
  18. $data= array('a', 'cd', 'efd');
  19. $column = 0;
  20. $direction = SORT_ASC;
  21. $type = SORT_REGULAR;
  22. $res =TableSort::sort_table($data, $column, $direction, $type);
  23. $this->assertTrue(is_array($res));
  24. //var_dump($res);
  25. }
  26. /* private method
  27. public function testIsNumericColumn(){
  28. $data=array('aeiou', 'abcde', 'acedrf');
  29. $column=0;
  30. $res = TableSort::is_numeric_column($data, $column);
  31. if(!is_numeric($res)):
  32. $this->assertTrue(is_bool($res));
  33. endif;
  34. $this->assertTrue($res === 1 || $res === 0);
  35. //var_dump($res);
  36. }
  37. public function testIsDateColumn(){
  38. $data=array();
  39. $column='';
  40. $res = TableSort::is_date_column($data, $column);
  41. if(is_bool($res))
  42. $this->assertTrue(($res));
  43. else{
  44. $this->assertTrue(is_numeric($res));
  45. }
  46. //var_dump($res);
  47. }
  48. public function testIsImageColumn(){
  49. $data=array();
  50. $column='';
  51. $res = TableSort::is_image_column($data, $column);
  52. if(is_bool($res)){
  53. $this->assertTrue(is_bool($res));
  54. $this->assertTrue($res);
  55. }
  56. else{
  57. $this->assertTrue(is_numeric($res));
  58. }
  59. //var_dump($res);
  60. }
  61. */
  62. public function testSortTableConfig(){
  63. $data=array('a','b','c','d','e','z');
  64. $column = 0;
  65. $direction = SORT_ASC;
  66. $column_show=null;
  67. $column_order=null;
  68. $type = SORT_REGULAR;
  69. $res = TableSort::sort_table_config($data, $column, $direction, $column_show, $column_order,$type);
  70. $this->assertTrue(is_array($res));
  71. //var_dump($res);
  72. }
  73. }
  74. ?>