1 search.test SearchCommentCountToggleTestCase::testSearchCommentCountToggle()

Verify that comment count displays correctly based on comment status of node.

File

core/modules/search/tests/search.test, line 1051
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->backdropPost('user', $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->backdropPost('user', $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->backdropPost('user', $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');
}