You are here

public function FieldCrudTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldCrudTest.php \Drupal\Tests\field\Kernel\FieldCrudTest::setUp()

Set the default field storage backend for fields created during tests.

Overrides FieldKernelTestBase::setUp

File

core/modules/field/tests/src/Kernel/FieldCrudTest.php, line 41

Class

FieldCrudTest
Create field entities by attaching fields to entities.

Namespace

Drupal\Tests\field\Kernel

Code

public function setUp() {
  parent::setUp();
  $this->fieldStorageDefinition = [
    'field_name' => mb_strtolower($this
      ->randomMachineName()),
    'entity_type' => 'entity_test',
    'type' => 'test_field',
  ];
  $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
  $this->fieldStorage
    ->save();
  $this->fieldDefinition = [
    'field_name' => $this->fieldStorage
      ->getName(),
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
  ];
}