function DefaultTableMappingTest::testGetDedicatedTableName

Tests get dedicated table name.

@legacy-covers ::getDedicatedDataTableName @legacy-covers ::getDedicatedRevisionTableName

Attributes

#[DataProvider('providerTestGetDedicatedTableName')]

File

core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php, line 461

Class

DefaultTableMappingTest
Tests Drupal\Core\Entity\Sql\DefaultTableMapping.

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testGetDedicatedTableName($info, $expected_data_table, $expected_revision_table) : void {
  $entity_type_id = $info['entity_type_id'];
  $field_name = $info['field_name'];
  $definition = $this->setUpDefinition($field_name, []);
  $definition->expects($this->any())
    ->method('getTargetEntityTypeId')
    ->willReturn($entity_type_id);
  $definition->expects($this->any())
    ->method('getUniqueStorageIdentifier')
    ->willReturn($entity_type_id . '-' . $field_name);
  $this->entityType
    ->expects($this->any())
    ->method('getBaseTable')
    ->willReturn($info['entity_type_id']);
  $this->entityType
    ->expects($this->any())
    ->method('isTranslatable')
    ->willReturn(FALSE);
  $this->entityType
    ->expects($this->any())
    ->method('isRevisionable')
    ->willReturn(FALSE);
  $table_mapping = new TestDefaultTableMapping($this->entityType, [], $info['prefix']);
  $this->assertSame($expected_data_table, $table_mapping->getDedicatedDataTableName($definition));
  $this->assertSame($expected_revision_table, $table_mapping->getDedicatedRevisionTableName($definition));
}

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