function EntitySchemaTest::testIdentifierSchema
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php \Drupal\KernelTests\Core\Entity\EntitySchemaTest::testIdentifierSchema()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php \Drupal\KernelTests\Core\Entity\EntitySchemaTest::testIdentifierSchema()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php \Drupal\KernelTests\Core\Entity\EntitySchemaTest::testIdentifierSchema()
Tests the installed storage schema for identifier fields.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntitySchemaTest.php, line 388
Class
- EntitySchemaTest
- Tests the default entity storage schema handler.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testIdentifierSchema() {
$this->installEntitySchema('entity_test_rev');
$key_value_store = \Drupal::keyValue('entity.storage_schema.sql');
$id_schema = $key_value_store->get('entity_test_rev.field_schema_data.id', []);
$revision_id_schema = $key_value_store->get('entity_test_rev.field_schema_data.revision_id', []);
$expected_id_schema = [
'entity_test_rev' => [
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => TRUE,
],
],
],
'entity_test_rev_revision' => [
'fields' => [
'id' => [
'type' => 'int',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => TRUE,
],
],
],
];
$this->assertEquals($expected_id_schema, $id_schema);
$expected_revision_id_schema = [
'entity_test_rev' => [
'fields' => [
'revision_id' => [
'type' => 'int',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => FALSE,
],
],
],
'entity_test_rev_revision' => [
'fields' => [
'revision_id' => [
'type' => 'serial',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => TRUE,
],
],
],
];
$this->assertEquals($expected_revision_id_schema, $revision_id_schema);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.