You are here

protected function KernelTransactionTestBase::prepareTargetEntityLastTransactionField in Transaction 8

Creates an entity reference field to the latest executed transaction.

1 call to KernelTransactionTestBase::prepareTargetEntityLastTransactionField()
KernelTransactionTestBase::setUp in tests/src/Kernel/KernelTransactionTestBase.php

File

tests/src/Kernel/KernelTransactionTestBase.php, line 138

Class

KernelTransactionTestBase
Base class for kernel tests of the Transaction module.

Namespace

Drupal\Tests\transaction\Kernel

Code

protected function prepareTargetEntityLastTransactionField() {

  // Entity reference field to the last executed transaction.
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'field_last_transaction',
    'type' => 'entity_reference',
    'entity_type' => 'entity_test',
    'settings' => [
      'target_type' => 'transaction',
    ],
  ]);
  $field_storage
    ->save();
  FieldConfig::create([
    'label' => 'Last transaction',
    'field_storage' => $field_storage,
    'bundle' => 'entity_test',
  ])
    ->save();
}