You are here

public function SortsFunctionalBase::setUp in Search API sorts 8

Overrides SearchApiBrowserTestBase::setUp

1 call to SortsFunctionalBase::setUp()
TranslationTest::setUp in tests/src/Functional/TranslationTest.php
1 method overrides SortsFunctionalBase::setUp()
TranslationTest::setUp in tests/src/Functional/TranslationTest.php

File

tests/src/Functional/SortsFunctionalBase.php, line 43

Class

SortsFunctionalBase
Base class for sorts web tests.

Namespace

Drupal\Tests\search_api_sorts\Functional

Code

public function setUp() : void {
  parent::setUp();

  // Create an index and server to work with.
  $this
    ->getTestServer();
  $this
    ->getTestIndex();
  $this->indexId = 'database_search_index';
  $index = Index::load($this->indexId);

  // Do not use a batch for tracking the initial items after creating an
  // index when running the tests via the GUI. Otherwise the test fails.
  \Drupal::state()
    ->set('search_api_use_tracking_batch', FALSE);

  // Create content.
  $this
    ->setUpExampleStructure();
  $this
    ->insertExampleContent();
  $this->escapedDisplayId = 'views_page---search_api_sorts_test_view__page_1';
  $this->displayId = 'views_page:search_api_sorts_test_view__page_1';

  // Log in, so we can test all the things.
  $this
    ->drupalLogin($this->adminUser);

  // Index all items.
  \Drupal::getContainer()
    ->get('search_api.index_task_manager')
    ->addItemsAll($index);
  $this
    ->assertEquals(5, $this
    ->indexItems($this->indexId));
}