social.lib.test.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'social.lib.php');
  3. require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  4. require_once(api_get_path(LIBRARY_PATH).'api.lib.php');
  5. class TestSocial extends UnitTestCase{
  6. //public $social;
  7. public function __construct() {
  8. $this->UnitTestCase('Social network library - main/inc/lib/social.lib.test.php');
  9. }
  10. /*
  11. public function setUp(){
  12. $this->social = new SocialManager();
  13. }
  14. public function tearDown(){
  15. $this->social = null;
  16. }
  17. */
  18. public function testShowListTypeFriends(){
  19. $res =SocialManager::show_list_type_friends();
  20. $this->assertTrue($res);
  21. $this->assertTrue(is_array($res));
  22. //var_dump($res);
  23. }
  24. public function testGetRelationTypeByName (){
  25. $relation_type_name=1;
  26. $res = SocialManager::get_relation_type_by_name($relation_type_name);
  27. if(is_null($res))
  28. {
  29. $this->assertNull($res);
  30. $this->assertTrue(is_null($res));
  31. } else
  32. {
  33. $this->assertTrue(is_numeric($res));
  34. $this->assertTrue($res);
  35. }
  36. //var_dump($res);
  37. }
  38. public function testGetRelationBetweenContacts (){
  39. $user_id=1;
  40. $user_friend=3;
  41. $res =SocialManager::get_relation_between_contacts($user_id,$user_friend);
  42. if(is_numeric($res)){
  43. $this->assertFalse($res);
  44. $this->assertTrue(is_numeric($res));
  45. } else
  46. {
  47. $this->assertTrue(is_string($res));
  48. $this->assertTrue($res);
  49. }
  50. //var_dump($res);
  51. }
  52. public function testGetListWebPathUserInvitationByUserId(){
  53. $user_id=1;
  54. $res = SocialManager::get_list_web_path_user_invitation_by_user_id($user_id);
  55. if(is_array($res))
  56. $this->assertTrue(is_array($res));
  57. else
  58. $this->assertTrue(is_null($res));
  59. //var_dump($res);
  60. }
  61. public function testSendInvitationFriend(){
  62. $user_id=1;
  63. $friend_id=3;
  64. $message_title='hello';
  65. $message_content='hola';
  66. $res = SocialManager::send_invitation_friend($user_id,$friend_id,$message_title,$message_content);
  67. if(!is_null($res)):
  68. $this->assertTrue(is_bool($res));
  69. $this->assertTrue(is_bool($res===true || $res === false));
  70. endif;
  71. //var_dump($res);
  72. }
  73. public function testGetMessageNumberInvitationByUserId(){
  74. $user_receiver_id=3;
  75. $res = SocialManager::get_message_number_invitation_by_user_id($user_receiver_id);
  76. if(is_string($res)):
  77. $this->assertTrue(is_numeric($res));
  78. endif;
  79. //var_dump($res);
  80. }
  81. public function testGetListInvitationOfFriendsByUserId(){
  82. $user_id=1;
  83. $res = SocialManager::get_list_invitation_of_friends_by_user_id($user_id);
  84. $this->assertTrue(is_array($res));
  85. //var_dump($res);
  86. }
  87. public function testInvitationAccepted(){
  88. $user_send_id=1;
  89. $user_receiver_id=3;
  90. $res = SocialManager::invitation_accepted($user_send_id,$user_receiver_id);
  91. $this->assertTrue(is_null($res));
  92. //var_dump($res);
  93. }
  94. public function testInvitationDenied(){
  95. $user_send_id=1;
  96. $user_receiver_id=3;
  97. $res = SocialManager::invitation_denied($user_send_id,$user_receiver_id);
  98. $this->assertTrue(is_null($res));
  99. //var_dump($res);
  100. }
  101. public function testQualifyFriend(){
  102. $id_friend_qualify=2;
  103. $type_qualify=1;
  104. $res = SocialManager::qualify_friend($id_friend_qualify,$type_qualify);
  105. $this->assertTrue(is_null($res));
  106. //var_dump($res);
  107. }
  108. public function testSendInvitationFriendUser(){
  109. global $_course, $charset;
  110. ob_start();
  111. $userfriend_id = 1;
  112. $subject_message = 'test';
  113. $content_message = 'this message is a test';
  114. $res = SocialManager::send_invitation_friend_user ($userfriend_id,$subject_message,$content_message);
  115. ob_end_clean();
  116. if(is_string($res)){
  117. $this->assertTrue($res);
  118. $this->assertTrue(is_string($res));
  119. } else {
  120. $this->assertTrue(is_bool($res));
  121. $this->assertTrue($res === false);
  122. }
  123. //var_dump($res);
  124. }
  125. }
  126. ?>