public function SqlContentEntityStorageTest::testGetTableMappingTranslatable in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingTranslatable()
Tests getTableMapping() with a non-revisionable, translatable 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 602 - Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest.
Class
- SqlContentEntityStorageTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorage @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testGetTableMappingTranslatable(array $entity_keys) {
// This allows to re-use the data provider.
$entity_keys['langcode'] = 'langcode';
$this->entityType
->expects($this
->atLeastOnce())
->method('isTranslatable')
->will($this
->returnValue(TRUE));
$this->entityType
->expects($this
->atLeastOnce())
->method('getDataTable')
->will($this
->returnValue('entity_test_field_data'));
$this->entityType
->expects($this
->any())
->method('getKey')
->will($this
->returnValueMap(array(
array(
'id',
$entity_keys['id'],
),
array(
'uuid',
$entity_keys['uuid'],
),
array(
'bundle',
$entity_keys['bundle'],
),
array(
'langcode',
$entity_keys['langcode'],
),
)));
$this
->setUpEntityStorage();
$mapping = $this->entityStorage
->getTableMapping();
$expected = array(
'entity_test',
'entity_test_field_data',
);
$this
->assertEquals($expected, $mapping
->getTableNames());
$expected = array_values(array_filter($entity_keys));
$actual = $mapping
->getFieldNames('entity_test');
$this
->assertEquals($expected, $actual);
// The UUID is not stored on the data table.
$expected = array_values(array_filter(array(
$entity_keys['id'],
$entity_keys['bundle'],
$entity_keys['langcode'],
)));
$actual = $mapping
->getFieldNames('entity_test_field_data');
$this
->assertEquals($expected, $actual);
$expected = array();
$actual = $mapping
->getExtraColumns('entity_test');
$this
->assertEquals($expected, $actual);
$actual = $mapping
->getExtraColumns('entity_test_field_data');
$this
->assertEquals($expected, $actual);
}