You are here

protected function EntityUsageTest::setUp in Entity Usage 8

Same name and namespace in other branches
  1. 8.4 tests/src/Kernel/EntityUsageTest.php \Drupal\Tests\entity_usage\Kernel\EntityUsageTest::setUp()
  2. 8.2 tests/src/Kernel/EntityUsageTest.php \Drupal\Tests\entity_usage\Kernel\EntityUsageTest::setUp()
  3. 8.3 tests/src/Kernel/EntityUsageTest.php \Drupal\Tests\entity_usage\Kernel\EntityUsageTest::setUp()

Overrides EntityKernelTestBase::setUp

File

tests/src/Kernel/EntityUsageTest.php, line 71

Class

EntityUsageTest
Tests the basic API operations of our tracking service..

Namespace

Drupal\Tests\entity_usage\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this->injectedDatabase = $this->container
    ->get('database');
  $this
    ->installSchema('entity_usage', [
    'entity_usage',
  ]);
  $this->tableName = 'entity_usage';

  // Create two test entities.
  $this->testEntities = $this
    ->getTestEntities();
  $this->state = \Drupal::state();
  \Drupal::service('event_dispatcher')
    ->addListener(Events::USAGE_ADD, [
    $this,
    'usageAddEventRecorder',
  ]);
  \Drupal::service('event_dispatcher')
    ->addListener(Events::USAGE_DELETE, [
    $this,
    'usageDeleteEventRecorder',
  ]);
  \Drupal::service('event_dispatcher')
    ->addListener(Events::BULK_TARGETS_DELETE, [
    $this,
    'usageBulkTargetDeleteEventRecorder',
  ]);
  \Drupal::service('event_dispatcher')
    ->addListener(Events::BULK_HOSTS_DELETE, [
    $this,
    'usageBulkHostsDeleteEventRecorder',
  ]);
}