You are here

function SearchCommentCountToggleTest::testSearchCommentCountToggle in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/Tests/SearchCommentCountToggleTest.php \Drupal\search\Tests\SearchCommentCountToggleTest::testSearchCommentCountToggle()

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

File

core/modules/search/src/Tests/SearchCommentCountToggleTest.php, line 87
Contains \Drupal\search\Tests\SearchCommentCountToggleTest.

Class

SearchCommentCountToggleTest
Tests that comment count display toggles properly on comment status of node.

Namespace

Drupal\search\Tests

Code

function testSearchCommentCountToggle() {

  // Search for the nodes by string in the node body.
  $edit = array(
    'keys' => "'SearchCommentToggleTestCase'",
  );
  $this
    ->drupalGet('search/node');

  // Test comment count display for nodes with comment status set to Open
  $this
    ->drupalPostForm(NULL, $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->searchableNodes['0 comments']
    ->set('comment', CommentItemInterface::CLOSED);
  $this->searchableNodes['0 comments']
    ->save();
  $this->searchableNodes['1 comment']
    ->set('comment', CommentItemInterface::CLOSED);
  $this->searchableNodes['1 comment']
    ->save();
  $this
    ->drupalPostForm(NULL, $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->searchableNodes['0 comments']
    ->set('comment', CommentItemInterface::HIDDEN);
  $this->searchableNodes['0 comments']
    ->save();
  $this->searchableNodes['1 comment']
    ->set('comment', CommentItemInterface::HIDDEN);
  $this->searchableNodes['1 comment']
    ->save();
  $this
    ->drupalPostForm(NULL, $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');
}