You are here

protected function FieldSqlStorageTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php \Drupal\system\Tests\Entity\FieldSqlStorageTest::setUp()

Performs setup tasks before each individual test method is run.

Overrides EntityUnitTestBase::setUp

File

core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php, line 79
Contains \Drupal\system\Tests\Entity\FieldSqlStorageTest.

Class

FieldSqlStorageTest
Tests Field SQL Storage .

Namespace

Drupal\system\Tests\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 = entity_create('field_storage_config', array(
    'field_name' => $this->fieldName,
    'entity_type' => $entity_type,
    'type' => 'test_field',
    'cardinality' => $this->fieldCardinality,
  ));
  $this->fieldStorage
    ->save();
  $this->field = entity_create('field_config', array(
    'field_storage' => $this->fieldStorage,
    'bundle' => $entity_type,
  ));
  $this->field
    ->save();

  /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
  $table_mapping = \Drupal::entityManager()
    ->getStorage($entity_type)
    ->getTableMapping();
  $this->tableMapping = $table_mapping;
  $this->table = $table_mapping
    ->getDedicatedDataTableName($this->fieldStorage);
  $this->revisionTable = $table_mapping
    ->getDedicatedRevisionTableName($this->fieldStorage);
}