You are here

function UserRelationshipsApiSocnetTestCase::testAllPendingTo in User Relationships 6

File

user_relationships_api/tests/user_relationships_api.socnet.test, line 133
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 testAllPendingTo() {
  $u1 = $this
    ->drupalCreateUser();
  $u2 = $this
    ->drupalCreateUser();
  $u3 = $this
    ->drupalCreateUser();
  $u4 = $this
    ->drupalCreateUser();

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

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

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

  //test relationships towards 1
  $result = module_invoke_all('socnet_all_pending_to', $u1->uid);
  $this
    ->assertTrue(count($result) == 2);
  $this
    ->assertTrue(in_array($u3->uid, $result));
  $this
    ->assertTrue(in_array($u4->uid, $result));
}