function SearchCommentCountToggleTest::testSearchCommentCountToggle
Same name in other branches
- 9 core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php \Drupal\Tests\search\Functional\SearchCommentCountToggleTest::testSearchCommentCountToggle()
- 8.9.x core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php \Drupal\Tests\search\Functional\SearchCommentCountToggleTest::testSearchCommentCountToggle()
- 11.x core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php \Drupal\Tests\search\Functional\SearchCommentCountToggleTest::testSearchCommentCountToggle()
Verify that comment count display toggles properly on comment status of node.
File
-
core/
modules/ search/ tests/ src/ Functional/ SearchCommentCountToggleTest.php, line 95
Class
- SearchCommentCountToggleTest
- Tests that comment count display toggles properly on comment status of node.
Namespace
Drupal\Tests\search\FunctionalCode
public function testSearchCommentCountToggle() : void {
// Search for the nodes by string in the node body.
$edit = [
'keys' => "'SearchCommentToggleTestCase'",
];
$this->drupalGet('search/node');
// Test comment count display for nodes with comment status set to Open
$this->submitForm($edit, 'Search');
$this->assertSession()
->pageTextContains('0 comments');
$this->assertSession()
->pageTextContains('1 comment');
// 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->submitForm($edit, 'Search');
$this->assertSession()
->pageTextNotContains('0 comments');
$this->assertSession()
->pageTextContains('1 comment');
// 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->submitForm($edit, 'Search');
$this->assertSession()
->pageTextNotContains('0 comments');
$this->assertSession()
->pageTextNotContains('1 comment');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.