function SqlContentEntityStorageSchemaTest::testRequiresEntityDataMigration
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityDataMigration()
- 10 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityDataMigration()
- 11.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageSchemaTest::testRequiresEntityDataMigration()
@covers ::requiresEntityDataMigration
@dataProvider providerTestRequiresEntityDataMigration
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageSchemaTest.php, line 1201
Class
- SqlContentEntityStorageSchemaTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testRequiresEntityDataMigration($updated_entity_type_definition, $original_entity_type_definition, $original_storage_has_data, $shared_table_structure_changed, $migration_required) {
$this->entityType = new ContentEntityType([
'id' => 'entity_test',
'entity_keys' => [
'id' => 'id',
],
]);
$this->storage
->expects($this->exactly(is_null($original_storage_has_data) || !$shared_table_structure_changed ? 0 : 1))
->method('hasData')
->willReturn($original_storage_has_data);
$connection = $this->getMockBuilder('Drupal\\Core\\Database\\Connection')
->disableOriginalConstructor()
->getMock();
$this->entityLastInstalledSchemaRepository
->expects($this->any())
->method('getLastInstalledDefinition')
->willReturn($this->entityType);
$this->entityLastInstalledSchemaRepository
->expects($this->any())
->method('getLastInstalledFieldStorageDefinitions')
->willReturn($this->storageDefinitions);
$this->storageSchema = $this->getMockBuilder('Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema')
->setConstructorArgs([
$this->entityTypeManager,
$this->entityType,
$this->storage,
$connection,
$this->entityFieldManager,
$this->entityLastInstalledSchemaRepository,
])
->setMethods([
'installedStorageSchema',
'hasSharedTableStructureChange',
])
->getMock();
$this->storageSchema
->expects($this->any())
->method('hasSharedTableStructureChange')
->with($updated_entity_type_definition, $original_entity_type_definition)
->willReturn($shared_table_structure_changed);
$this->assertEquals($migration_required, $this->storageSchema
->requiresEntityDataMigration($updated_entity_type_definition, $original_entity_type_definition));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.