function SearchConfigSettingsFormTest::setUp

Same name in other branches
  1. 8.9.x core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::setUp()
  2. 10 core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::setUp()
  3. 11.x core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php, line 51

Class

SearchConfigSettingsFormTest
Verify the search config settings form.

Namespace

Drupal\Tests\search\Functional

Code

protected function setUp() : void {
    parent::setUp();
    $this->drupalCreateContentType([
        'type' => 'page',
        'name' => 'Basic page',
    ]);
    // Log in as a user that can create and search content.
    $this->searchUser = $this->drupalCreateUser([
        'search content',
        'administer search',
        'administer nodes',
        'bypass node access',
        'access user profiles',
        'administer users',
        'administer blocks',
        'access site reports',
    ]);
    $this->drupalLogin($this->searchUser);
    // Add a single piece of content and index it.
    $node = $this->drupalCreateNode();
    $this->searchNode = $node;
    // Link the node to itself to test that it's only indexed once. The content
    // also needs the word "pizza" so we can use it as the search keyword.
    $body_key = 'body[0][value]';
    $edit[$body_key] = Link::fromTextAndUrl($node->label(), $node->toUrl())
        ->toString() . ' pizza sandwich';
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->container
        ->get('plugin.manager.search')
        ->createInstance('node_search')
        ->updateIndex();
    // Enable the search block.
    $this->drupalPlaceBlock('search_form_block');
    $this->drupalPlaceBlock('local_tasks_block', [
        'id' => 'local_tasks',
    ]);
    $this->drupalPlaceBlock('page_title_block');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.