function SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges()
- 10 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityStorageSchemaChanges()
@covers ::requiresEntityStorageSchemaChanges
@dataProvider providerTestRequiresEntityStorageSchemaChanges
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php, line 1259
Class
- SqlContentEntityStorageSchemaTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testRequiresEntityStorageSchemaChanges(bool $requires_change, bool $change_schema, bool $change_shared_table, ?string $method = NULL) : void {
$original = $this->createMock(ContentEntityTypeInterface::class);
$original->expects($this->any())
->method('id')
->willReturn('entity_test');
$original->expects($this->any())
->method('getKey')
->willReturn('id');
$updated = $this->createMock(ContentEntityTypeInterface::class);
$updated->expects($this->any())
->method('id')
->willReturn('entity_test');
$updated->expects($this->any())
->method('getKey')
->willReturn('id');
if ($method) {
$original->expects($this->once())
->method($method)
->willReturn(TRUE);
$updated->expects($this->once())
->method($method)
->willReturn(FALSE);
}
// Storage class changes should not impact this at all, and should not be
// checked.
$original->expects($this->never())
->method('getStorageClass');
$updated->expects($this->never())
->method('getStorageClass');
$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')
->willReturn($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));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.