You are here

public function SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields()
  2. 10 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields()

Tests getTableMapping() with a base field that requires a dedicated table.

@covers ::__construct @covers ::getTableMapping

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php, line 546
Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest.

Class

SqlContentEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testGetTableMappingSimpleWithDedicatedStorageFields() {
  $base_field_names = [
    'multi_valued_base_field',
  ];

  // Set up one entity key in order to have a base table.
  $this->fieldDefinitions = $this
    ->mockFieldDefinitions([
    'test_id',
  ]);

  // Set up the multi-valued base field.
  $this->fieldDefinitions += $this
    ->mockFieldDefinitions($base_field_names, [
    'hasCustomStorage' => FALSE,
    'isMultiple' => TRUE,
    'getTargetEntityTypeId' => 'entity_test',
  ]);
  $this
    ->setUpEntityStorage();
  $mapping = $this->entityStorage
    ->getTableMapping();
  $this
    ->assertEquals([
    'entity_test',
    'entity_test__multi_valued_base_field',
  ], $mapping
    ->getTableNames());
  $this
    ->assertEquals($base_field_names, $mapping
    ->getFieldNames('entity_test__multi_valued_base_field'));
  $extra_columns = [
    'bundle',
    'deleted',
    'entity_id',
    'revision_id',
    'langcode',
    'delta',
  ];
  $this
    ->assertEquals($extra_columns, $mapping
    ->getExtraColumns('entity_test__multi_valued_base_field'));
}