function FieldCrudTest::setUp

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldCrudTest.php \Drupal\Tests\field\Kernel\FieldCrudTest::setUp()
  2. 8.9.x core/modules/field/tests/src/Kernel/FieldCrudTest.php \Drupal\Tests\field\Kernel\FieldCrudTest::setUp()
  3. 11.x core/modules/field/tests/src/Kernel/FieldCrudTest.php \Drupal\Tests\field\Kernel\FieldCrudTest::setUp()

Overrides FieldKernelTestBase::setUp

File

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

Class

FieldCrudTest
Create field entities by attaching fields to entities.

Namespace

Drupal\Tests\field\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->fieldStorageDefinition = [
        'field_name' => $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',
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.