diff --git a/core/lib/Drupal/Core/Schema/SchemaData.php b/core/lib/Drupal/Core/Schema/SchemaData.php index cdd61a99bb..b3531d97cd 100644 --- a/core/lib/Drupal/Core/Schema/SchemaData.php +++ b/core/lib/Drupal/Core/Schema/SchemaData.php @@ -84,7 +84,6 @@ public function getSpecification($module, $table = NULL) { if (isset($schema[$table])) { return $schema[$table]; } - return []; } elseif (!empty($schema)) { return $schema; diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index 0c60491e57..38e12b30c2 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -158,8 +158,10 @@ public function testInstallSchema() { $this->installSchema($module, $table); $this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found."); + /** @var \Drupal\Core\Schema\SchemaDataInterface $schema_data */ + $schema_data = \Drupal::service('database.schema.data'); // Verify that the schema is known to Schema API. - $schema = \Drupal::service('database.schema.data')->getSpecification($module, $table); + $schema = $schema_data->getSpecification($module, $table); $this->assertTrue($schema, "'$table' table schema found."); // Verify that a unknown table from an enabled module throws an error. @@ -172,7 +174,7 @@ public function testInstallSchema() { $this->pass('Exception for non-retrievable schema found.'); } $this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found."); - $schema = \Drupal::service('database.schema.data')->getSpecification($module, $table); + $schema = $schema_data->getSpecification($module, $table); $this->assertFalse($schema, "'$table' table schema not found."); // Verify that a table from a unknown module cannot be installed. @@ -186,7 +188,7 @@ public function testInstallSchema() { $this->pass('Exception for non-retrievable schema found.'); } $this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found."); - $schema = \Drupal::service('database.schema.data')->getSpecification($module, $table); + $schema = $schema_data->getSpecification($module, $table); $this->assertTrue($schema, "'$table' table schema found."); // Verify that the same table can be installed after enabling the module.