You are here

public function DefaultTableMappingTest::testGetDedicatedTableName in Drupal 10

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

@covers ::getDedicatedDataTableName @covers ::getDedicatedRevisionTableName

@dataProvider providerTestGetDedicatedTableName

File

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

Class

DefaultTableMappingTest
@coversDefaultClass \Drupal\Core\Entity\Sql\DefaultTableMapping @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testGetDedicatedTableName($info, $expected_data_table, $expected_revision_table) {
  $entity_type_id = $info['entity_type_id'];
  $field_name = $info['field_name'];
  $definition = $this
    ->setUpDefinition($field_name, []);
  $definition
    ->expects($this
    ->any())
    ->method('getTargetEntityTypeId')
    ->will($this
    ->returnValue($entity_type_id));
  $definition
    ->expects($this
    ->any())
    ->method('getUniqueStorageIdentifier')
    ->will($this
    ->returnValue($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));
}