You are here

function SearchCommentCountToggleTestCase::testSearchCommentCountToggle in Drupal 7

Verify that comment count display toggles properly on comment status of node

File

modules/search/search.test, line 1099
Tests for search.module.

Class

SearchCommentCountToggleTestCase
Tests that comment count display toggles properly on comment status of node

Code

function testSearchCommentCountToggle() {

  // Search for the nodes by string in the node body.
  $edit = array(
    'search_block_form' => "'SearchCommentToggleTestCase'",
  );

  // Test comment count display for nodes with comment status set to Open
  $this
    ->drupalPost('', $edit, t('Search'));
  $this
    ->assertText(t('0 comments'), 'Empty comment count displays for nodes with comment status set to Open');
  $this
    ->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Open');

  // Test comment count display for nodes with comment status set to Closed
  $this->searchable_nodes['0 comments']->comment = COMMENT_NODE_CLOSED;
  node_save($this->searchable_nodes['0 comments']);
  $this->searchable_nodes['1 comment']->comment = COMMENT_NODE_CLOSED;
  node_save($this->searchable_nodes['1 comment']);
  $this
    ->drupalPost('', $edit, t('Search'));
  $this
    ->assertNoText(t('0 comments'), 'Empty comment count does not display for nodes with comment status set to Closed');
  $this
    ->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Closed');

  // Test comment count display for nodes with comment status set to Hidden
  $this->searchable_nodes['0 comments']->comment = COMMENT_NODE_HIDDEN;
  node_save($this->searchable_nodes['0 comments']);
  $this->searchable_nodes['1 comment']->comment = COMMENT_NODE_HIDDEN;
  node_save($this->searchable_nodes['1 comment']);
  $this
    ->drupalPost('', $edit, t('Search'));
  $this
    ->assertNoText(t('0 comments'), 'Empty comment count does not display for nodes with comment status set to Hidden');
  $this
    ->assertNoText(t('1 comment'), 'Non-empty comment count does not display for nodes with comment status set to Hidden');
}