You are here

protected function UserPointsTransactionTest::prepareTargetEntityLastTransactionField in User Points 8

Creates an entity reference field to the latest executed transaction.

Overrides KernelTransactionTestBase::prepareTargetEntityLastTransactionField

File

tests/src/Kernel/UserPointsTransactionTest.php, line 123

Class

UserPointsTransactionTest
Tests the user points transactor.

Namespace

Drupal\Tests\userpoints\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' => 'user',
    'settings' => [
      'target_type' => 'transaction',
    ],
  ]);
  $field_storage
    ->save();
  FieldConfig::create([
    'label' => 'Last transaction',
    'field_storage' => $field_storage,
    'bundle' => 'user',
  ])
    ->save();
}