You are here

public function CommentAlterPermissionTestCase::testViewCommentAlterations in Comment Alter 7

This function was copied from CommentAlterListTextTestCase::testOptionsSelectSingle(), which should pass for a privileged user, but fail for an unprivileged one.

File

./comment_alter.test, line 606
Functional tests for the Comment Alter module.

Class

CommentAlterPermissionTestCase
Functional tests for permissions.

Code

public function testViewCommentAlterations() {

  // START CommentAlterListTextTestCase::testOptionsSelectSingle().
  $field_name = $this
    ->createField('list_text', 'options_select', array(
    'settings' => array(
      'allowed_values' => array(
        1 => 'One',
        2 => 'Two',
        3 => 'Three',
      ),
    ),
    'cardinality' => 1,
  ));
  $this
    ->createNodeThenPostComment(array(
    $field_name => array(
      LANGUAGE_NONE => array(
        0 => array(
          'value' => 1,
        ),
      ),
    ),
  ), array(
    "{$field_name}[" . LANGUAGE_NONE . ']' => '2',
  ));
  $this
    ->assertCommentDiff(array(
    $field_name => array(
      array(
        'One',
        'Two',
      ),
    ),
  ));

  // END CommentAlterListTextTestCase::testOptionsSelectSingle().
  // Get the current URL so we can return here.
  $url = $this
    ->getUrl();

  // Switch to an unprivileged user.
  $unprivileged_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $this
    ->drupalLogin($unprivileged_user);

  // Return to the URL and assert that there are no comment alterations on it.
  $this
    ->drupalGet($url);
  $alterations = $this
    ->getCommentAlterations();
  $this
    ->assertTrue(empty($alterations));
}