function SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingSimpleWithDedicatedStorageFields()
  3. 11.x 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 545

Class

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

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testGetTableMappingSimpleWithDedicatedStorageFields() : void {
    $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'));
}

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