public function SqlContentEntityStorageTest::testSetTableMapping in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::testSetTableMapping()
Tests that setting a new table mapping also updates the table names.
@covers ::setTableMapping
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php, line 317 - 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 testSetTableMapping() {
$this->entityType
->expects($this
->any())
->method('isRevisionable')
->will($this
->returnValue(FALSE));
$this->entityType
->expects($this
->any())
->method('isTranslatable')
->will($this
->returnValue(FALSE));
$this->entityType
->expects($this
->any())
->method('getRevisionMetadataKeys')
->willReturn([]);
$this
->setUpEntityStorage();
$this
->assertSame('entity_test', $this->entityStorage
->getBaseTable());
$this
->assertNull($this->entityStorage
->getRevisionTable());
$this
->assertNull($this->entityStorage
->getDataTable());
$this
->assertNull($this->entityStorage
->getRevisionDataTable());
// Change the entity type definition and instantiate a new table mapping
// with it.
$updated_entity_type = $this
->createMock('Drupal\\Core\\Entity\\ContentEntityTypeInterface');
$updated_entity_type
->expects($this
->any())
->method('id')
->will($this
->returnValue($this->entityTypeId));
$updated_entity_type
->expects($this
->any())
->method('isRevisionable')
->will($this
->returnValue(TRUE));
$updated_entity_type
->expects($this
->any())
->method('isTranslatable')
->will($this
->returnValue(TRUE));
$table_mapping = new DefaultTableMapping($updated_entity_type, []);
$this->entityStorage
->setTableMapping($table_mapping);
$this
->assertSame('entity_test', $this->entityStorage
->getBaseTable());
$this
->assertSame('entity_test_revision', $this->entityStorage
->getRevisionTable());
$this
->assertSame('entity_test_field_data', $this->entityStorage
->getDataTable());
$this
->assertSame('entity_test_field_revision', $this->entityStorage
->getRevisionDataTable());
}