You are here

protected function EntityReferenceRevisionsFormatterTest::setUp in Entity Reference Revisions 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/EntityReferenceRevisionsFormatterTest.php, line 38

Class

EntityReferenceRevisionsFormatterTest
@coversDefaultClass \Drupal\entity_reference_revisions\Plugin\Field\FieldFormatter\EntityReferenceRevisionsEntityFormatter @group entity_reference_revisions

Namespace

Drupal\Tests\entity_reference_revisions\Kernel

Code

protected function setUp() {
  parent::setUp();

  // Create article content type.
  $values = [
    'type' => 'article',
    'name' => 'Article',
  ];
  $node_type = NodeType::create($values);
  $node_type
    ->save();
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('entity_test_composite');
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installSchema('node', [
    'node_access',
  ]);

  // Add the entity_reference_revisions field to article.
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'composite_reference',
    'entity_type' => 'node',
    'type' => 'entity_reference_revisions',
    'settings' => [
      'target_type' => 'entity_test_composite',
    ],
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'article',
  ]);
  $field
    ->save();
  $user = $this
    ->createUser([
    'administer entity_test composite relationship',
  ]);
  \Drupal::currentUser()
    ->setAccount($user);
}