You are here

function UserRelationshipsApiSocnetTestCase::testAllPendingFrom in User Relationships 6

File

user_relationships_api/tests/user_relationships_api.socnet.test, line 153
Social networking hook API testcase @author Alex Karshakevich http://drupal.org/user/183217

Class

UserRelationshipsApiSocnetTestCase
@file Social networking hook API testcase @author Alex Karshakevich http://drupal.org/user/183217

Code

function testAllPendingFrom() {
  $u1 = $this
    ->drupalCreateUser();
  $u2 = $this
    ->drupalCreateUser();
  $u3 = $this
    ->drupalCreateUser();
  $u4 = $this
    ->drupalCreateUser();

  //make approved requests from 1
  user_relationships_request_relationship($u1, $u2, $this->rtypes['oneway']->rtid, TRUE);

  //make pending requests from 1
  user_relationships_request_relationship($u1, $u3, $this->rtypes['approval']->rtid, FALSE);
  user_relationships_request_relationship($u1, $u4, $this->rtypes['approval-oneway']->rtid, FALSE);

  //and one towards 1
  user_relationships_request_relationship($u4, $u1, $this->rtypes['approval']->rtid, FALSE);

  //test 1's relationships
  $result = module_invoke_all('socnet_all_pending_from', $u1->uid);
  $this
    ->assertTrue(count($result) == 2);
  $this
    ->assertTrue(in_array($u3->uid, $result));
  $this
    ->assertTrue(in_array($u4->uid, $result));
  $result = module_invoke_all('socnet_all_pending_from', $u1->uid, 'approval-oneway');
  $this
    ->assertTrue(count($result) == 1);
  $this
    ->assertTrue(in_array($u4->uid, $result));
  $result = module_invoke_all('socnet_all_pending_from', $u1->uid, NULL, 'one-way');
  $this
    ->assertTrue(count($result) == 1);
  $this
    ->assertTrue(in_array($u4->uid, $result));
  $result = module_invoke_all('socnet_all_pending_from', $u1->uid, NULL, 'two-way');
  $this
    ->assertTrue(count($result) == 1);
  $this
    ->assertTrue(in_array($u3->uid, $result));
}