diff --git a/core/modules/simpletest/simpletest.install b/core/modules/simpletest/simpletest.install index c1422e6..e94d625 100644 --- a/core/modules/simpletest/simpletest.install +++ b/core/modules/simpletest/simpletest.install @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\Environment; +use Drupal\Core\Database\Database; /** * Minimum value of PHP memory_limit for SimpleTest. @@ -142,7 +143,7 @@ function simpletest_schema() { ), 'primary key' => array('message_id'), 'indexes' => array( - 'reporter' => array('test_class', 'message_id'), + 'test_id' => array('test_id'), ), ); $schema['simpletest_test_id'] = array( @@ -180,3 +181,20 @@ function simpletest_uninstall() { // Delete verbose test output and any other testing framework files. file_unmanaged_delete_recursive('public://simpletest'); } + +/** + * @addtogroup updates-8.2.0 + * @{ + */ + +/** + * Remove reporter index and add test_id index to simpletest table. + */ +function simpletest_update_8200() { + Database::getConnection()->schema()->dropIndex('simpletest', 'reporter'); + Database::getConnection()->schema()->addIndex('simpletest', 'test_id', ['test_id'], simpletest_schema()['simpletest']); +} + +/** + * @} End of "addtogroup updates-8.2.0". + */ diff --git a/core/modules/simpletest/src/Tests/Update/UpdateSimpletestTableSchemaTest.php b/core/modules/simpletest/src/Tests/Update/UpdateSimpletestTableSchemaTest.php new file mode 100644 index 0000000..819507c --- /dev/null +++ b/core/modules/simpletest/src/Tests/Update/UpdateSimpletestTableSchemaTest.php @@ -0,0 +1,36 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz', + ]; + } + + /** + * Test that our table update ran against our simulated table. + */ + public function testUpdateHookN() { + $this->assertTrue(Database::getConnection()->schema()->indexExists('simpletest', 'reporter')); + $this->assertFalse(Database::getConnection()->schema()->indexExists('simpletest', 'test_id')); + $this->runUpdates(); + $this->assertFalse(Database::getConnection()->schema()->indexExists('simpletest', 'reporter')); + $this->assertTrue(Database::getConnection()->schema()->indexExists('simpletest', 'test_id')); + } + +}