You are here

public function SqlContentEntityStorageTest::testGetTableMappingSimpleWithFields in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingSimpleWithFields()

Tests getTableMapping() with a simple entity type with some base fields.

@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 425
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 testGetTableMappingSimpleWithFields(array $entity_keys) {
  $base_field_names = array(
    'title',
    'description',
    'owner',
  );
  $field_names = array_merge(array_values(array_filter($entity_keys)), $base_field_names);
  $this->fieldDefinitions = $this
    ->mockFieldDefinitions($field_names);
  $this
    ->setUpEntityStorage();
  $mapping = $this->entityStorage
    ->getTableMapping();
  $this
    ->assertEquals(array(
    'entity_test',
  ), $mapping
    ->getTableNames());
  $this
    ->assertEquals($field_names, $mapping
    ->getFieldNames('entity_test'));
  $this
    ->assertEquals(array(), $mapping
    ->getExtraColumns('entity_test'));
}