.../fixtures/update/rest-module-installed.php | 38 ++++++++++++++++++++++ .../Update/RestSettingsDeletionUpdateTest.php | 37 +++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/core/modules/rest/tests/fixtures/update/rest-module-installed.php b/core/modules/rest/tests/fixtures/update/rest-module-installed.php new file mode 100644 index 0000000000..476dc9b5ce --- /dev/null +++ b/core/modules/rest/tests/fixtures/update/rest-module-installed.php @@ -0,0 +1,38 @@ +insert('key_value') + ->fields([ + 'collection' => 'system.schema', + 'name' => 'rest', + 'value' => 'i:8000;', + ]) + ->execute(); + +// Update core.extension. +$extensions = $connection->select('config') + ->fields('config', ['data']) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); +$extensions = unserialize($extensions); +$extensions['module']['rest'] = 0; +$extensions['module']['serialization'] = 0; +$extensions['module']['basic_auth'] = 0; +$connection->update('config') + ->fields([ + 'data' => serialize($extensions), + ]) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute(); diff --git a/core/modules/rest/tests/src/Functional/Update/RestSettingsDeletionUpdateTest.php b/core/modules/rest/tests/src/Functional/Update/RestSettingsDeletionUpdateTest.php new file mode 100644 index 0000000000..b1a7b384b2 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/Update/RestSettingsDeletionUpdateTest.php @@ -0,0 +1,37 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz', + __DIR__ . '/../../../fixtures/update/rest-module-installed.php', + ]; + } + + /** + * Ensures that update hook is run for "rest" module. + */ + public function testUpdate() { + $rest_settings = $this->config('rest.settings'); + $this->assertSame([], $rest_settings->getRawData()); + + $this->runUpdates(); + + $rest_settings = \Drupal::configFactory()->get('rest.settings'); + $this->assertSame([], $rest_settings->getRawData()); + } + +}