diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php index 0a97a63..d690011 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php @@ -108,9 +108,9 @@ function testEnableModulesInstall() { */ function testEnableModulesInstallContainer() { // Install Node module. - $this->enableModules(array('field', 'node')); + $this->enableModules(array('user', 'field', 'node')); - $this->installSchema('node', array('node', 'node_field_data')); + $this->installEntitySchema('node', array('node', 'node_field_data')); // Perform an entity query against node. $query = \Drupal::entityQuery('node'); // Disable node access checks, since User module is not enabled. @@ -125,7 +125,7 @@ function testEnableModulesInstallContainer() { */ function testInstallSchema() { $module = 'entity_test'; - $table = 'entity_test'; + $table = 'entity_test_example'; // Verify that we can install a table from the module schema. $this->installSchema($module, $table); $this->assertTrue(db_table_exists($table), "'$table' database table found."); @@ -172,6 +172,18 @@ function testInstallSchema() { } /** + * Tests expected behavior of installEntitySchema(). + */ + function testInstallEntitySchema() { + $entity = 'entity_test'; + // The entity_test Entity has a field that depends on the User module. + $this->enableModules(array('user')); + // Verity that the entity schema is created properly. + $this->installEntitySchema($entity); + $this->assertTrue(db_table_exists($entity), "'$entity' database table found."); + } + + /** * Tests expected behavior of installConfig(). */ function testInstallConfig() { diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install index f2db594..015b067 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.install +++ b/core/modules/system/tests/modules/entity_test/entity_test.install @@ -36,3 +36,22 @@ function entity_test_install() { ->save(); } } + +/** + * Implements hook_schema(). + */ +function entity_test_schema() { + // Schema for simple entity. + $schema['entity_test_example'] = array( + 'description' => 'Stores entity_test items.', + 'fields' => array( + 'id' => array( + 'type' => 'serial', + 'not null' => TRUE, + 'description' => 'Primary Key: Unique entity-test item ID.', + ), + ), + 'primary key' => array('id'), + ); + return $schema; +}