You are here

public function SqlContentEntityStorageTest::testGetTableMappingSimple in Drupal 10

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

Tests getTableMapping() with a simple entity type.

@covers ::__construct @covers ::getTableMapping

@dataProvider providerTestGetTableMappingSimple()

Parameters

string[] $entity_keys: A map of entity keys to use for the mocked entity type.

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php, line 478
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 testGetTableMappingSimple(array $entity_keys) {
  $this->entityType
    ->expects($this
    ->any())
    ->method('getKey')
    ->willReturnMap([
    [
      'id',
      $entity_keys['id'],
    ],
    [
      'uuid',
      $entity_keys['uuid'],
    ],
    [
      'bundle',
      $entity_keys['bundle'],
    ],
  ]);
  $this
    ->setUpEntityStorage();
  $mapping = $this->entityStorage
    ->getTableMapping();
  $this
    ->assertEquals([
    'entity_test',
  ], $mapping
    ->getTableNames());
  $expected = array_values(array_filter($entity_keys));
  $this
    ->assertEquals($expected, $mapping
    ->getFieldNames('entity_test'));
  $this
    ->assertEquals([], $mapping
    ->getExtraColumns('entity_test'));
}