specific_fields_manager.lib.test.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
  3. class TestSpecificFieldsManager extends UnitTestCase {
  4. public function __construct() {
  5. $this->UnitTestCase('Specific (extra) fields library - main/inc/lib/specific_fields_manager.lib.test.php');
  6. }
  7. function testadd_specific_field() {
  8. $name='';
  9. $res=add_specific_field($name);
  10. if(!is_bool($res)) {$this->assertTrue(is_string($res));}
  11. $this->assertTrue(is_bool($res));
  12. //var_dump($res);
  13. }
  14. function testadd_specific_field_value() {
  15. $id_specific_field='';
  16. $course_id='';
  17. $tool_id='';
  18. $ref_id='';
  19. $value='';
  20. $res=add_specific_field_value($id_specific_field, $course_id, $tool_id, $ref_id, $value);
  21. $this->assertTrue(is_bool($res));
  22. //var_dump($res);
  23. }
  24. function testdelete_all_specific_field_value() {
  25. $course_id='';
  26. $id_specific_field='';
  27. $tool_id='';
  28. $ref_id='';
  29. $res=delete_all_specific_field_value($course_id, $id_specific_field, $tool_id, $ref_id);
  30. $this->assertTrue(is_null($res));
  31. //var_dump($res);
  32. }
  33. function testdelete_all_values_for_item() {
  34. $course_id='';
  35. $tool_id='';
  36. $ref_id='';
  37. $id_specific_field='';
  38. $res=delete_all_specific_field_value($course_id, $id_specific_field, $tool_id, $ref_id);
  39. $this->assertTrue(is_null($res));
  40. //var_dump($res);
  41. }
  42. function testdelete_specific_field() {
  43. $id='';
  44. $res=delete_specific_field($id);
  45. $this->assertTrue(is_null($res));
  46. //var_dump($res);
  47. }
  48. function testedit_specific_field() {
  49. $id='';
  50. $name='';
  51. $res=edit_specific_field($id,$name);
  52. $this->assertTrue(is_null($res));
  53. //var_dump($res);
  54. }
  55. function testget_specific_field_code_from_name() {
  56. $name='';
  57. $res=get_specific_field_code_from_name($name);
  58. $this->assertTrue(is_string($res));
  59. //var_dump($res);
  60. }
  61. function testget_specific_field_list() {
  62. $res=get_specific_field_list($conditions = array(), $order_by = array());
  63. $this->assertTrue(is_array($res));
  64. //var_dump($res);
  65. }
  66. function testget_specific_field_values_list() {
  67. $res=get_specific_field_values_list($conditions = array(), $order_by = array());
  68. $this->assertTrue(is_array($res));
  69. //var_dump($res);
  70. }
  71. function testget_specific_field_values_list_by_prefix() {
  72. $prefix='';
  73. $course_code='';
  74. $tool_id='';
  75. $ref_id=1;
  76. $table_sf = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
  77. $table_sfv = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
  78. $sql = sprintf($sql, $table_sf, $table_sfv, $prefix, $course_code, $tool_id, $ref_id);
  79. $res=get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id);
  80. $return_array = array();
  81. $this->assertTrue(is_null($res));
  82. $this->assertTrue(is_array($return_array));
  83. //var_dump($res);
  84. //var_dump($return_array);
  85. }
  86. }
  87. ?>