public function SqlContentEntityStorageTest::testGetTableMappingRevisionable in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testGetTableMappingRevisionable()
Tests getTableMapping() with a revisionable, non-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 587 - 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 testGetTableMappingRevisionable(array $entity_keys) {
// This allows to re-use the data provider.
$entity_keys = [
'id' => $entity_keys['id'],
'revision' => 'test_revision',
'bundle' => $entity_keys['bundle'],
'uuid' => $entity_keys['uuid'],
];
$this->entityType
->expects($this
->exactly(4))
->method('isRevisionable')
->will($this
->returnValue(TRUE));
$this->entityType
->expects($this
->any())
->method('getKey')
->will($this
->returnValueMap([
[
'id',
$entity_keys['id'],
],
[
'uuid',
$entity_keys['uuid'],
],
[
'bundle',
$entity_keys['bundle'],
],
[
'revision',
$entity_keys['revision'],
],
]));
$this->entityType
->expects($this
->any())
->method('getRevisionMetadataKeys')
->will($this
->returnValue([]));
$this
->setUpEntityStorage();
$mapping = $this->entityStorage
->getTableMapping();
$expected = [
'entity_test',
'entity_test_revision',
];
$this
->assertEquals($expected, $mapping
->getTableNames());
$expected = array_values(array_filter($entity_keys));
$this
->assertEquals($expected, $mapping
->getFieldNames('entity_test'));
$expected = [
$entity_keys['id'],
$entity_keys['revision'],
];
$this
->assertEquals($expected, $mapping
->getFieldNames('entity_test_revision'));
$this
->assertEquals([], $mapping
->getExtraColumns('entity_test'));
$this
->assertEquals([], $mapping
->getExtraColumns('entity_test_revision'));
}