IdentifierFieldSchemaTypeUpdateTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Update/IdentifierFieldSchemaTypeUpdateTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class IdentifierFieldSchemaTypeUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../fixtures/update/drupal-8.8.0.bare.standard.php.gz',
];
}
public function testSystemUpdate8901() {
$key_value_store = \Drupal::keyValue('entity.storage_schema.sql');
$id_schema = $key_value_store
->get('node.field_schema_data.nid', []);
$revision_id_schema = $key_value_store
->get('node.field_schema_data.vid', []);
$this
->assertEquals('int', $id_schema['node']['fields']['nid']['type']);
$this
->assertEquals('int', $id_schema['node_revision']['fields']['nid']['type']);
$this
->assertEquals('int', $revision_id_schema['node']['fields']['vid']['type']);
$this
->assertEquals('int', $revision_id_schema['node_revision']['fields']['vid']['type']);
$this
->runUpdates();
$id_schema = $key_value_store
->get('node.field_schema_data.nid', []);
$revision_id_schema = $key_value_store
->get('node.field_schema_data.vid', []);
$this
->assertEquals('serial', $id_schema['node']['fields']['nid']['type']);
$this
->assertEquals('int', $id_schema['node_revision']['fields']['nid']['type']);
$this
->assertEquals('int', $revision_id_schema['node']['fields']['vid']['type']);
$this
->assertEquals('serial', $revision_id_schema['node_revision']['fields']['vid']['type']);
$node_storage = \Drupal::entityTypeManager()
->getStorage('node');
$node = $node_storage
->create([
'title' => 'Test update',
'type' => 'article',
]);
$node
->save();
$node = $node_storage
->load($node
->id());
$this
->assertEquals('Test update', $node
->label());
}
}