function FieldSqlStorageTest::setUp

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php \Drupal\KernelTests\Core\Entity\FieldSqlStorageTest::setUp()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php \Drupal\KernelTests\Core\Entity\FieldSqlStorageTest::setUp()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php \Drupal\KernelTests\Core\Entity\FieldSqlStorageTest::setUp()

Overrides EntityKernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php, line 74

Class

FieldSqlStorageTest
Tests Field SQL Storage .

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function setUp() {
    parent::setUp();
    $this->installEntitySchema('entity_test_rev');
    $entity_type = 'entity_test_rev';
    $this->fieldName = strtolower($this->randomMachineName());
    $this->fieldCardinality = 4;
    $this->fieldStorage = FieldStorageConfig::create([
        'field_name' => $this->fieldName,
        'entity_type' => $entity_type,
        'type' => 'test_field',
        'cardinality' => $this->fieldCardinality,
    ]);
    $this->fieldStorage
        ->save();
    $this->field = FieldConfig::create([
        'field_storage' => $this->fieldStorage,
        'bundle' => $entity_type,
    ]);
    $this->field
        ->save();
    
    /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
    $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type)
        ->getTableMapping();
    $this->tableMapping = $table_mapping;
    $this->table = $table_mapping->getDedicatedDataTableName($this->fieldStorage);
    $this->revisionTable = $table_mapping->getDedicatedRevisionTableName($this->fieldStorage);
}

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