public function SearchCommentCountToggleTest::testSearchCommentCountToggle in Drupal 9
Same name and namespace in other branches
- 8 core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php \Drupal\Tests\search\Functional\SearchCommentCountToggleTest::testSearchCommentCountToggle()
- 10 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 90
Class
- SearchCommentCountToggleTest
- Tests that comment count display toggles properly on comment status of node.
Namespace
Drupal\Tests\search\FunctionalCode
public function testSearchCommentCountToggle() {
// 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');
}