protected function SearchCommentCountToggleTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php \Drupal\Tests\search\Functional\SearchCommentCountToggleTest::setUp()
- 9 core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php \Drupal\Tests\search\Functional\SearchCommentCountToggleTest::setUp()
File
- core/
modules/ search/ tests/ src/ Functional/ SearchCommentCountToggleTest.php, line 49
Class
- SearchCommentCountToggleTest
- Tests that comment count display toggles properly on comment status of node.
Namespace
Drupal\Tests\search\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
// Create searching user.
$this->searchingUser = $this
->drupalCreateUser([
'search content',
'access content',
'access comments',
'post comments',
'skip comment approval',
]);
// Log in with sufficient privileges.
$this
->drupalLogin($this->searchingUser);
// Add a comment field.
$this
->addDefaultCommentField('node', 'article');
// Create initial nodes.
$node_params = [
'type' => 'article',
'body' => [
[
'value' => 'SearchCommentToggleTestCase',
],
],
];
$this->searchableNodes['1 comment'] = $this
->drupalCreateNode($node_params);
$this->searchableNodes['0 comments'] = $this
->drupalCreateNode($node_params);
// Create a comment array
$edit_comment = [];
$edit_comment['subject[0][value]'] = $this
->randomMachineName();
$edit_comment['comment_body[0][value]'] = $this
->randomMachineName();
// Post comment to the test node with comment
$this
->drupalGet('comment/reply/node/' . $this->searchableNodes['1 comment']
->id() . '/comment');
$this
->submitForm($edit_comment, 'Save');
// First update the index. This does the initial processing.
$this->container
->get('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
}