You are here

protected function ViewsEntitySchemaSubscriberIntegrationTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::setUp()
  2. 10 core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php \Drupal\Tests\views\Kernel\EventSubscriber\ViewsEntitySchemaSubscriberIntegrationTest::setUp()

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides ViewsKernelTestBase::setUp

File

core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php, line 74

Class

ViewsEntitySchemaSubscriberIntegrationTest
Tests \Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber

Namespace

Drupal\Tests\views\Kernel\EventSubscriber

Code

protected function setUp($import_test_views = TRUE) {
  parent::setUp();
  $this->eventDispatcher = $this->container
    ->get('event_dispatcher');
  $this->eventSubscriber = $this->container
    ->get('views.entity_schema_subscriber');
  $this->entityDefinitionUpdateManager = $this->container
    ->get('entity.definition_update_manager');
  $this->entityTypeManager = $this->container
    ->get('entity_type.manager');
  $this->state = $this->container
    ->get('state');
  $this->database = $this->container
    ->get('database');

  // Install every entity type's schema that wasn't installed in the parent
  // method.
  foreach (array_diff_key($this->entityTypeManager
    ->getDefinitions(), array_flip([
    'user',
    'entity_test',
  ])) as $entity_type_id => $entity_type) {
    $this
      ->installEntitySchema($entity_type_id);
  }
}