|
|
|
|
@ -7,8 +7,6 @@ Mock::generate('Display'); |
|
|
|
|
Mock::generate('UserManager'); |
|
|
|
|
Mock::generate('MessageManager'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestSocial extends UnitTestCase{ |
|
|
|
|
/* |
|
|
|
|
public $social; |
|
|
|
|
@ -18,7 +16,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setUp(){ |
|
|
|
|
$this->social = new UserFriend(); |
|
|
|
|
$this->social = new SocialManager(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function tearDown(){ |
|
|
|
|
@ -30,7 +28,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$friend_id=4; |
|
|
|
|
$my_user_id=1; |
|
|
|
|
$relation_type=2; |
|
|
|
|
$res= UserFriend::register_friend ($friend_id,$my_user_id,$relation_type); |
|
|
|
|
$res= SocialManager::register_friend ($friend_id,$my_user_id,$relation_type); |
|
|
|
|
$instans->expectCallCount(Database); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
@ -43,7 +41,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$instans= new MockDatabase(); |
|
|
|
|
$instans1= new MockDatabase(); |
|
|
|
|
$friend_id=4; |
|
|
|
|
$res = UserFriend::removed_friend ($friend_id); |
|
|
|
|
$res = SocialManager::removed_friend ($friend_id); |
|
|
|
|
$instans->expectCallCount(Database,8,'' ); |
|
|
|
|
$instans1->expectMaximumCallCount(Database,10,''); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
@ -57,7 +55,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
public function testShowListTypeFriends(){ |
|
|
|
|
$instans= new MockDatabase(); |
|
|
|
|
$instans1= new MockDatabase(); |
|
|
|
|
$res =UserFriend::show_list_type_friends(); |
|
|
|
|
$res =SocialManager::show_list_type_friends(); |
|
|
|
|
$instans->expectOnce(Database); |
|
|
|
|
$instans1->expectMaximumCallCount(Database,10,''); |
|
|
|
|
$this->assertTrue(is_object($instans) || is_object($instans1)); |
|
|
|
|
@ -70,7 +68,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
|
|
|
|
|
public function testGetRelationTypeByName (){ |
|
|
|
|
$relation_type_name=1; |
|
|
|
|
$res = UserFriend::get_relation_type_by_name ($relation_type_name); |
|
|
|
|
$res = SocialManager::get_relation_type_by_name ($relation_type_name); |
|
|
|
|
if(!is_null($res)): |
|
|
|
|
$this->assertTrue(is_numeric($res)); |
|
|
|
|
$this->assertTrue($res); |
|
|
|
|
@ -84,7 +82,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$instans2= new MockDatabase(); |
|
|
|
|
$user_id=1; |
|
|
|
|
$user_friend=3; |
|
|
|
|
$res =UserFriend::get_relation_between_contacts ($user_id,$user_friend); |
|
|
|
|
$res =SocialManager::get_relation_between_contacts ($user_id,$user_friend); |
|
|
|
|
$instans->expectOnce(Database); |
|
|
|
|
$instans1->expectMinimumCallCount(Database); |
|
|
|
|
$instans2->expectMaximumCallCount(Database); |
|
|
|
|
@ -106,7 +104,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$user_id = 1; |
|
|
|
|
$id_group=3; |
|
|
|
|
$search_name='group'; |
|
|
|
|
$res = UserFriend::get_list_id_friends_by_user_id ($user_id,$id_group,$search_name); |
|
|
|
|
$res = SocialManager::get_friends_id ($user_id,$id_group,$search_name); |
|
|
|
|
$instans->expectOnce(Database); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
@ -119,7 +117,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$user_id=1; |
|
|
|
|
$id_group=null; |
|
|
|
|
$search_name=null; |
|
|
|
|
$res = UserFriend::get_list_path_web_by_user_id ($user_id,$id_group,$search_name); |
|
|
|
|
$res = SocialManager::get_list_path_web_by_user_id ($user_id,$id_group,$search_name); |
|
|
|
|
$instans->expectOnce(UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'],'web',false,true)); |
|
|
|
|
if(!($res===true)): |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
@ -132,7 +130,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
public function testGetListWebPathUserInvitationByUserId(){ |
|
|
|
|
$instans = new MockUserManager(); |
|
|
|
|
$user_id=1; |
|
|
|
|
$res = UserFriend::get_list_web_path_user_invitation_by_user_id($user_id); |
|
|
|
|
$res = SocialManager::get_list_web_path_user_invitation_by_user_id($user_id); |
|
|
|
|
$instans->expectOnce(UserManager::get_user_picture_path_by_id($values_ids['user_sender_id'],'web',false,true)); |
|
|
|
|
if(is_array($res)) |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
@ -149,7 +147,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$friend_id=3; |
|
|
|
|
$message_title='hello'; |
|
|
|
|
$message_content='hola'; |
|
|
|
|
$res = UserFriend ::send_invitation_friend ($user_id,$friend_id,$message_title,$message_content); |
|
|
|
|
$res = SocialManager ::send_invitation_friend ($user_id,$friend_id,$message_title,$message_content); |
|
|
|
|
$instans->expectMaximumCallCount(Database); |
|
|
|
|
if(!is_null($res)): |
|
|
|
|
$this->assertTrue(is_bool($res)); |
|
|
|
|
@ -163,7 +161,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
public function testGetMessageNumberInvitationByUserId(){ |
|
|
|
|
$instans = new MockDatabase(); |
|
|
|
|
$user_receiver_id=3; |
|
|
|
|
$res = UserFriend::get_message_number_invitation_by_user_id ($user_receiver_id); |
|
|
|
|
$res = SocialManager::get_message_number_invitation_by_user_id ($user_receiver_id); |
|
|
|
|
$instans->expectMaximumCallCount(Database); |
|
|
|
|
if(is_string($res)): |
|
|
|
|
$this->assertTrue(is_numeric($res)); |
|
|
|
|
@ -177,7 +175,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
public function testGetListInvitationOfFriendsByUserId(){ |
|
|
|
|
$instans = new MockDatabase(); |
|
|
|
|
$user_id=1; |
|
|
|
|
$res = UserFriend::get_list_invitation_of_friends_by_user_id ($user_id); |
|
|
|
|
$res = SocialManager::get_list_invitation_of_friends_by_user_id ($user_id); |
|
|
|
|
$instans->expectCallCount(Database,3,''); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
@ -190,7 +188,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$instans1= new MockDatabase(); |
|
|
|
|
$user_send_id=1; |
|
|
|
|
$user_receiver_id=3; |
|
|
|
|
$res = UserFriend::invitation_accepted ($user_send_id,$user_receiver_id); |
|
|
|
|
$res = SocialManager::invitation_accepted ($user_send_id,$user_receiver_id); |
|
|
|
|
$instans->expectOnce(Database::get_main_table(TABLE_MAIN_MESSAGE)); |
|
|
|
|
$instans1->expectOnce(Database::query($sql,__FILE__,__LINE__)); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
@ -205,7 +203,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$instans = new MockDatabase(); |
|
|
|
|
$user_send_id=1; |
|
|
|
|
$user_receiver_id=3; |
|
|
|
|
$res = UserFriend::invitation_denied($user_send_id,$user_receiver_id); |
|
|
|
|
$res = SocialManager::invitation_denied($user_send_id,$user_receiver_id); |
|
|
|
|
$instans->expectOnce(Database::query($sql,__FILE__,__LINE__)); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
@ -219,7 +217,7 @@ class TestSocial extends UnitTestCase{ |
|
|
|
|
$instans = new MockDatabase(); |
|
|
|
|
$id_friend_qualify=2; |
|
|
|
|
$type_qualify=1; |
|
|
|
|
$res = UserFriend::qualify_friend($id_friend_qualify,$type_qualify); |
|
|
|
|
$res = SocialManager::qualify_friend($id_friend_qualify,$type_qualify); |
|
|
|
|
$instans->expectOnce(Database::query($sql,__FILE__,__LINE__)); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
|