diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php index d3e1ba4..9275be8 100644 --- a/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -425,7 +425,7 @@ public function fieldExists($table, $column) { */ abstract public function copyTable($source, $destination); - /** + /**j * Add a new field to a table. * * @param $table @@ -446,7 +446,7 @@ public function fieldExists($table, $column) { * or index including it in this array. See db_change_field() for more * explanation why. * - * @throws Drupal\Core\Database\SchemaObjectDoesNotExistException + * @throws Drupal\Core\Database\SchemaObjectDoesNotExistExceptionV * If the specified table doesn't exist. * @throws Drupal\Core\Database\SchemaObjectExistsException * If the specified table already has a field by that name. diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php index 4c0085b..05866b9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php @@ -8,6 +8,8 @@ namespace Drupal\system\Tests\Database; use Drupal\Core\Database\Database; +use Drupal\Core\Database\SchemaObjectDoesNotExistException; +use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\simpletest\UnitTestBase; /** @@ -100,6 +102,25 @@ function testSchema() { $count = db_select('test_table3')->countQuery()->execute()->fetchField(); $this->assertEqual($count, 0, 'The new table has no content.'); + // Ensure that the proper exceptions are thrown for db_copy_table(). + $fail = FALSE; + try { + db_copy_table('test_table4', 'test_table5'); + } + catch (SchemaObjectDoesNotExistException $e) { + $fail = TRUE; + } + $this->assertTrue($fail, 'Ensure that db_copy_table throws an exception when the source table does not exists.'); + + $fail = FALSE; + try { + db_copy_table('test_table2', 'test_table3'); + } + catch (SchemaObjectExistsException $e) { + $fail = TRUE; + } + $this->assertTrue($fail, 'Ensure that db_copy_table throws an exception when the destination table does already exists.'); + // We need the default so that we can insert after the rename. db_field_set_default('test_table2', 'test_field', 0); $this->assertFalse($this->tryInsert(), 'Insert into the old table failed.');