cdn.install | 30 -------- .../Update/CdnDefaultSettingsUpdateTest.php | 90 ---------------------- .../Update/CdnSchemeSettingsUpdateTest.php | 46 ----------- .../Update/CdnStreamWrapperSettingsUpdateTest.php | 46 ----------- 4 files changed, 212 deletions(-) diff --git a/cdn.install b/cdn.install index ea95d92..7227a41 100644 --- a/cdn.install +++ b/cdn.install @@ -5,36 +5,6 @@ * Update functions for the CDN module. */ -/** - * Update the default settings if they are not modified by the user. - */ -function cdn_update_8001() { - $cdn_settings = \Drupal::configFactory()->getEditable('cdn.settings'); - $mapping = $cdn_settings->get('mapping'); - if ($mapping['type'] === 'simple' && $mapping['conditions'] === []) { - $cdn_settings->set('mapping.conditions', [ - 'not' => [ - 'extensions' => ['css', 'js'], - ], - ]); - $cdn_settings->save(); - } -} - -/** - * Add the new "stream wrappers" setting, set it to its default initial value. - */ -function cdn_update_8002() { - \Drupal::configFactory()->getEditable('cdn.settings')->set('stream_wrappers', ['public'])->save(); -} - -/** - * Add the new "scheme" setting, set it to its default initial value. - */ -function cdn_update_8003() { - \Drupal::configFactory()->getEditable('cdn.settings')->set('scheme', '//')->save(); -} - /** * Force container & cache rebuild upon upgrading from 8.x-3.x to 4.x. */ diff --git a/tests/src/Functional/Update/CdnDefaultSettingsUpdateTest.php b/tests/src/Functional/Update/CdnDefaultSettingsUpdateTest.php deleted file mode 100644 index 13d73c8..0000000 --- a/tests/src/Functional/Update/CdnDefaultSettingsUpdateTest.php +++ /dev/null @@ -1,90 +0,0 @@ -databaseDumpFiles = [ - DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz', - __DIR__ . '/../../../fixtures/update/drupal-8.cdn-cdn_update_8001.php', - ]; - } - - /** - * Tests default settings can be detected, and are updated. - * - * It's possible to automatically update the settings as long as the only - * thing that's modified by the end user is the 'domain' (NULL by default). - */ - public function testDefaultSettingsAreUpdated() { - $expected_original_mapping = [ - 'type' => 'simple', - 'domain' => 'cdn.example.com', - 'conditions' => [], - ]; - $expected_updated_mapping = [ - 'type' => 'simple', - 'domain' => 'cdn.example.com', - 'conditions' => [ - 'not' => [ - 'extensions' => ['css', 'js'], - ], - ], - ]; - - // Make sure we have the expected values before the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertSame($expected_original_mapping, $cdn_settings->get('mapping')); - - $this->runUpdates(); - - // Make sure we have the expected values after the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertSame($expected_updated_mapping, $cdn_settings->get('mapping')); - } - - /** - * Tests customized settings can be detected, and are ignored. - * - * We consider the CDN mapping settings "customized" as soon as the 'type' or - * 'conditions' keys are modified. - */ - public function testCustomizedSettingsAreIgnored() { - // First, customize the settings, like an end user would. - $this->config('cdn.settings')->set('mapping.conditions', ['extensions' => ['zip']])->save(); - - $expected_mapping = [ - 'type' => 'simple', - 'domain' => 'cdn.example.com', - 'conditions' => [ - 'extensions' => ['zip'], - ], - ]; - - // Make sure we have the expected values before the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertSame($expected_mapping, $cdn_settings->get('mapping')); - - $this->runUpdates(); - - // Make sure we have the expected values after the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertSame($expected_mapping, $cdn_settings->get('mapping')); - } - -} diff --git a/tests/src/Functional/Update/CdnSchemeSettingsUpdateTest.php b/tests/src/Functional/Update/CdnSchemeSettingsUpdateTest.php deleted file mode 100644 index 2f8cf94..0000000 --- a/tests/src/Functional/Update/CdnSchemeSettingsUpdateTest.php +++ /dev/null @@ -1,46 +0,0 @@ -databaseDumpFiles = [ - DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz', - __DIR__ . '/../../../fixtures/update/drupal-8.cdn-cdn_update_8001.php', - ]; - } - - /** - * Tests default settings can be detected, and are updated. - * - * It's possible to automatically update the settings as long as the only - * thing that's modified by the end user is the 'domain' (NULL by default). - */ - public function testStreamWrapperSettingsAdded() { - // Make sure we have the expected values before the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertNull($cdn_settings->get('scheme')); - - $this->runUpdates(); - - // Make sure we have the expected values after the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertSame('//', $cdn_settings->get('scheme')); - } - -} diff --git a/tests/src/Functional/Update/CdnStreamWrapperSettingsUpdateTest.php b/tests/src/Functional/Update/CdnStreamWrapperSettingsUpdateTest.php deleted file mode 100644 index a2bfdc9..0000000 --- a/tests/src/Functional/Update/CdnStreamWrapperSettingsUpdateTest.php +++ /dev/null @@ -1,46 +0,0 @@ -databaseDumpFiles = [ - DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz', - __DIR__ . '/../../../fixtures/update/drupal-8.cdn-cdn_update_8001.php', - ]; - } - - /** - * Tests default settings can be detected, and are updated. - * - * It's possible to automatically update the settings as long as the only - * thing that's modified by the end user is the 'domain' (NULL by default). - */ - public function testStreamWrapperSettingsAdded() { - // Make sure we have the expected values before the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertNull($cdn_settings->get('stream_wrappers')); - - $this->runUpdates(); - - // Make sure we have the expected values after the update. - $cdn_settings = $this->config('cdn.settings'); - $this->assertSame(['public'], $cdn_settings->get('stream_wrappers')); - } - -}