You are here

private function ForumAccessTestCase::testForumAccessDumpDebugInfo in Forum Access 6

This function is called when the program detects an error. It gives extra information so that the error can be fixed. hopefully :)

12 calls to ForumAccessTestCase::testForumAccessDumpDebugInfo()
ForumAccessTestCase::testForumAccessAddModerator in ./forum_access.test
This function adds a user as a moderator to a forum (must be used by the admin user!)
ForumAccessTestCase::testForumAccessCreateComment in ./forum_access.test
This function test if the user can create a comment Three steps: is there a create link, does the create comment page opens and can the new comment be saved
ForumAccessTestCase::testForumAccessCreateForum in ./forum_access.test
This function creates a new forum (must be used by the admin user!)
ForumAccessTestCase::testForumAccessCreateReply in ./forum_access.test
This function test if the user can create a reply on a comment Three steps: is there a create link, does the create reply page opens and can the new reply on a comment be saved
ForumAccessTestCase::testForumAccessCreateTopic in ./forum_access.test
This function test if the user can create a topic Three steps: is there a create link, does the create topic page opens and can the new topic be saved

... See full list

File

./forum_access.test, line 1190
Test file for forum_access.module.

Class

ForumAccessTestCase
This is the base class for forum access testing.

Code

private function testForumAccessDumpDebugInfo($content_type = '', $content_id = 0) {
  if ($content_type == 'comment' && intval($content_id) > 0) {
    $comment = _comment_load($content_id);
    if ($comment && $comment->cid > 0) {
      $this
        ->pass('The comment owner is: ' . ($comment->uid > 0 ? $this->testForumAccessUidToName[$comment->uid] : t('Anonymous')), 'Debug');
      $topic = node_load($comment->nid);
      if ($topic && $topic->nid > 0) {
        $this
          ->pass('The topic owner is: ' . ($topic->uid > 0 ? $this->testForumAccessUidToName[$topic->uid] : t('Anonymous')), 'Debug');
      }
    }
  }
  if ($content_type == 'topic' && intval($content_id) > 0) {
    $topic = node_load($content_id);
    if ($topic && $topic->nid > 0) {
      $this
        ->pass('The topic owner is: ' . ($topic->uid > 0 ? $this->testForumAccessUidToName[$topic->uid] : t('Anonymous')), 'Debug');
    }
  }
  $this
    ->pass('The current user is: ' . (empty($this->testForumAccessCurrentUsername) ? 'anonymous' : $this->testForumAccessCurrentUsername), 'Debug');
  if ($this->loggedInUser) {

    // Check the moderator status.
    $moderator_status_set = $this->testForumAccessCurrentUsername != 'admin_user' && in_array($this->testForumAccessUsers[$this->testForumAccessCurrentUsername]->uid, $this->testForumAccessModerators) ? TRUE : FALSE;
    $moderator_status_database = $this->testForumAccessCurrentUsername != 'admin_user' && $this
      ->testForumAccessGetModeratorStatus($this->testForumAccessUsers[$this->testForumAccessCurrentUsername]->uid) ? TRUE : FALSE;
    if ($moderator_status_set == $moderator_status_database) {
      $this
        ->pass('The moderator status is: ' . ($moderator_status_set ? 'TRUE' : 'FALSE'), 'Debug');
    }
    else {
      $this
        ->pass('Set moderator status is: ' . ($moderator_status_set ? 'TRUE' : 'FALSE'), 'Debug');
      $this
        ->pass('Database moderator status is: ' . ($moderator_status_database ? 'TRUE' : 'FALSE'), 'Debug');
    }

    // Check the permissions of the logged-in user.
    $permissions_set = count($this->testForumAccessPermissions[$this->testForumAccessCurrentUsername]) > 0 ? $this->testForumAccessPermissions[$this->testForumAccessCurrentUsername] : array(
      t('none'),
    );
    if ($this->testForumAccessCurrentUsername == 'admin_user') {
      $permissions_database = $this
        ->testForumAccessGetPermissionsUser($this->testForumAccessAdminUser->uid, TRUE);
    }
    else {
      $permissions_database = $this
        ->testForumAccessGetPermissionsUser($this->testForumAccessUsers[$this->testForumAccessCurrentUsername]->uid, TRUE);
    }
    $permissions_error = FALSE;
    foreach ($permissions_set as $perm) {
      if (!in_array($perm, $permissions_database)) {
        $permissions_error = TRUE;
      }
    }
    foreach ($permissions_database as $perm) {
      if (!in_array($perm, $permissions_set)) {
        $permissions_error = TRUE;
      }
    }
    if (!$permissions_error) {
      $this
        ->pass('The permissions are: ' . implode(', ', $permissions_set), 'Debug');
    }
    else {
      $this
        ->pass('Set permissions are: ' . implode(', ', $permissions_set), 'Debug');
      if ($this->testForumAccessCurrentUsername == 'admin_user') {
        $this
          ->pass('Database permissions are: ' . implode(', ', $this
          ->testForumAccessGetPermissionsUser($this->testForumAccessAdminUser->uid, TRUE)), 'Debug');
      }
      else {
        $this
          ->pass('Database permissions are: ' . implode(', ', $this
          ->testForumAccessGetPermissionsUser($this->testForumAccessUsers[$this->testForumAccessCurrentUsername]->uid, TRUE)), 'Debug');
      }
    }
  }
  else {

    // Check the permissions for anonymous.
    $permissions_set = count($this->testForumAccessPermissionsAnonymous) > 0 ? $this->testForumAccessPermissionsAnonymous : array(
      t('none'),
    );
    $permissions_database = $this
      ->testForumAccessGetPermissionsAnonymousUser(TRUE);
    $permissions_error = FALSE;
    foreach ($permissions_set as $perm) {
      if (!in_array($perm, $permissions_database)) {
        $permissions_error = TRUE;
      }
    }
    foreach ($permissions_database as $perm) {
      if (!in_array($perm, $permissions_set)) {
        $permissions_error = TRUE;
      }
    }
    if (!$permissions_error) {
      $this
        ->pass('The permissions are: ' . implode(', ', $permissions_set), 'Debug');
    }
    else {
      $this
        ->pass('Set permissions are: ' . implode(', ', $permissions_set), 'Debug');
      $this
        ->pass('Database permissions are: ' . implode(', ', $permissions_database), 'Debug');
    }
  }

  // Check the forum grants.
  $forum_grants_set = array_keys(array_filter($this->testForumAccessGrants, create_function('$grant', 'return $grant;')));
  $forum_grants_database = array_keys(array_filter($this
    ->testForumAccessGetForumGrants(), create_function('$grant', 'return $grant;')));
  $forum_grants_error = FALSE;
  foreach ($forum_grants_set as $grant) {
    if (!in_array($grant, $forum_grants_database)) {
      $forum_grants_error = TRUE;
    }
  }
  foreach ($forum_grants_database as $grant) {
    if (!in_array($grant, $forum_grants_set)) {
      $forum_grants_error = TRUE;
    }
  }
  if (!$forum_grants_error) {
    $this
      ->pass('The forum grants are: ' . implode(', ', $forum_grants_set), 'Debug');
  }
  else {
    $this
      ->pass('Set forum grants are: ' . implode(', ', $forum_grants_set), 'Debug');
    $this
      ->pass('Database forum grants are: ' . implode(', ', $forum_grants_database), 'Debug');
  }
  $this
    ->verbose('URL: ' . $this
    ->getUrl() . '<hr />' . $this
    ->drupalGetContent(), 'Debug');
}