function CommentInterfaceTest::testCommentLinks

Tests comment links.

The output of comment links depends on various environment conditions:

  • Various Comment module configuration settings, user registration settings, and user access permissions.
  • Whether the user is authenticated or not, and whether any comments exist.

To account for all possible cases, this test creates permutations of all possible conditions and tests the expected appearance of comment links in each environment.

File

modules/comment/comment.test, line 682

Class

CommentInterfaceTest

Code

function testCommentLinks() {
    // Bartik theme alters comment links, so use a different theme.
    theme_enable(array(
        'garland',
    ));
    variable_set('theme_default', 'garland');
    // Remove additional user permissions from $this->web_user added by setUp(),
    // since this test is limited to anonymous and authenticated roles only.
    user_role_delete(key($this->web_user->roles));
    // Matrix of possible environmental conditions and configuration settings.
    // See setEnvironment() for details.
    $conditions = array(
        'authenticated' => array(
            FALSE,
            TRUE,
        ),
        'comment count' => array(
            FALSE,
            TRUE,
        ),
        'access comments' => array(
            0,
            1,
        ),
        'post comments' => array(
            0,
            1,
        ),
        'form' => array(
            COMMENT_FORM_BELOW,
            COMMENT_FORM_SEPARATE_PAGE,
        ),
        // USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL is irrelevant for this
        // test; there is only a difference between open and closed registration.
'user_register' => array(
            USER_REGISTER_VISITORS,
            USER_REGISTER_ADMINISTRATORS_ONLY,
        ),
    );
    $environments = $this->generatePermutations($conditions);
    foreach ($environments as $info) {
        $this->assertCommentLinks($info);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.