You are here

protected function EntityReferenceRevisionsCompositeTest::setUp in Entity Reference Revisions 8

Overrides EntityKernelTestBase::setUp

File

tests/src/Kernel/EntityReferenceRevisionsCompositeTest.php, line 63

Class

EntityReferenceRevisionsCompositeTest
Tests the entity_reference_revisions composite relationship.

Namespace

Drupal\Tests\entity_reference_revisions\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test_composite');
  $this
    ->installSchema('node', [
    'node_access',
  ]);

  // Create article content type.
  NodeType::create([
    'type' => 'article',
    'name' => 'Article',
  ])
    ->save();

  // Create the reference to the composite entity test.
  $field_storage = FieldStorageConfig::create(array(
    'field_name' => 'composite_reference',
    'entity_type' => 'node',
    'type' => 'entity_reference_revisions',
    'settings' => array(
      'target_type' => 'entity_test_composite',
    ),
  ));
  $field_storage
    ->save();
  $field = FieldConfig::create(array(
    'field_storage' => $field_storage,
    'bundle' => 'article',
    'translatable' => FALSE,
  ));
  $field
    ->save();

  // Inject database connection, entity type manager and cron for the tests.
  $this->database = \Drupal::database();
  $this->entityTypeManager = \Drupal::entityTypeManager();
  $this->cron = \Drupal::service('cron');
}