You are here

protected function ViewsDisplayCachingTest::setUp in Search API 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Views/ViewsDisplayCachingTest.php, line 74

Class

ViewsDisplayCachingTest
Tests the Search API caching plugins for Views.

Namespace

Drupal\Tests\search_api\Kernel\Views

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installSchema('search_api', [
    'search_api_item',
  ]);
  $this
    ->installEntitySchema('entity_test_mulrev_changed');
  $this
    ->installEntitySchema('search_api_task');
  $this
    ->installConfig([
    'search_api',
    'search_api_test_example_content',
    'search_api_test_db',
    'search_api_test_views',
  ]);
  $this->entityTypeManager = $this->container
    ->get('entity_type.manager');
  $this->viewExecutableFactory = $this->container
    ->get('views.executable');

  // Use the test search index from the search_api_test_db module.
  $this->index = Index::load('database_search_index');

  // Use a test cache backend that allows to tamper with the request time so
  // we can test time based caching.
  $this->cache = new TestMemoryBackend();
  $this->container
    ->set('cache.data', $this->cache);

  // Create some demo content and index it.
  $this
    ->createDemoContent();
  $this->index
    ->indexItems();
}