public function SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges in Drupal 8
@covers ::requiresEntityStorageSchemaChanges
@dataProvider providerTestRequiresEntityStorageSchemaChanges
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php, line 1308
Class
- SqlContentEntityStorageSchemaTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testRequiresEntityStorageSchemaChanges(ContentEntityTypeInterface $updated, ContentEntityTypeInterface $original, $requires_change, $change_schema, $change_shared_table) {
$this->entityType = new ContentEntityType([
'id' => 'entity_test',
'entity_keys' => [
'id' => 'id',
],
]);
$this
->setUpStorageSchema();
$table_mapping = new TestSqlContentDefaultTableMapping($this->entityType, $this->storageDefinitions);
$table_mapping
->setFieldNames('entity_test', array_keys($this->storageDefinitions));
$table_mapping
->setExtraColumns('entity_test', [
'default_langcode',
]);
$this->storageSchema
->expects($this
->any())
->method('getTableMapping')
->will($this
->returnValue($table_mapping));
// Setup storage schema.
if ($change_schema) {
$this->storageSchema
->expects($this
->once())
->method('loadEntitySchemaData')
->willReturn([]);
}
else {
$expected = [
'entity_test' => [
'primary key' => [
'id',
],
],
];
$this->storageSchema
->expects($this
->any())
->method('loadEntitySchemaData')
->willReturn($expected);
}
if ($change_shared_table) {
$this->storageSchema
->expects($this
->once())
->method('hasSharedTableNameChanges')
->willReturn(TRUE);
}
$this
->assertEquals($requires_change, $this->storageSchema
->requiresEntityStorageSchemaChanges($updated, $original));
}