You are here

public function NodeCommentBlockWebTest::testAnonymousUsers in Node Comment Block 7.2

Test showing a block to anonymous users.

File

./node_comment_block.test, line 74
Tests for node_comment_block.module

Class

NodeCommentBlockWebTest
Functional tests for node_comment_block.

Code

public function testAnonymousUsers() {
  user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
    'access comments' => TRUE,
    'post comments' => FALSE,
  ));
  $account = $this
    ->drupalCreateUser(array(
    'administer blocks',
    'create article content',
  ));
  $this
    ->drupalLogin($account);

  // Place the node comments block into a region.
  $this
    ->drupalPost(self::BLOCK_CONFIGURE_PATH, array(
    'regions[bartik]' => 'sidebar_second',
  ), t('Save block'));
  $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertNoRaw(self::COMMENT_BLOCK_HTML, 'The comments block is not visible.');

  // Show the block to anonymous users.
  $this
    ->drupalLogin($account);
  $this
    ->drupalPost(self::BLOCK_CONFIGURE_PATH, array(
    'regions[bartik]' => 'sidebar_second',
    'show_anonymous' => TRUE,
  ), t('Save block'));
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertRaw(self::COMMENT_BLOCK_HTML, 'The comments block is visible.');
}