You are here

protected function SearchConfigSettingsFormTest::setUp in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/search/src/Tests/SearchConfigSettingsFormTest.php \Drupal\search\Tests\SearchConfigSettingsFormTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides SearchTestBase::setUp

File

core/modules/search/src/Tests/SearchConfigSettingsFormTest.php, line 40
Contains \Drupal\search\Tests\SearchConfigSettingsFormTest.

Class

SearchConfigSettingsFormTest
Verify the search config settings form.

Namespace

Drupal\search\Tests

Code

protected function setUp() {
  parent::setUp();

  // Login as a user that can create and search content.
  $this->searchUser = $this
    ->drupalCreateUser(array(
    '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] = \Drupal::l($node
    ->label(), $node
    ->urlInfo()) . ' pizza sandwich';
  $this
    ->drupalPostForm('node/' . $node
    ->id() . '/edit', $edit, t('Save and keep published'));
  $this->container
    ->get('plugin.manager.search')
    ->createInstance('node_search')
    ->updateIndex();
  search_update_totals();

  // Enable the search block.
  $this
    ->drupalPlaceBlock('search_form_block');
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->drupalPlaceBlock('page_title_block');
}