CdnDefaultSettingsUpdateTest.php in CDN 8.3
File
tests/src/Functional/Update/CdnDefaultSettingsUpdateTest.php
View source
<?php
namespace Drupal\Tests\cdn\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class CdnDefaultSettingsUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->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',
];
}
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',
],
],
],
];
$cdn_settings = $this
->config('cdn.settings');
$this
->assertSame($expected_original_mapping, $cdn_settings
->get('mapping'));
$this
->runUpdates();
$cdn_settings = $this
->config('cdn.settings');
$this
->assertSame($expected_updated_mapping, $cdn_settings
->get('mapping'));
}
public function testCustomizedSettingsAreIgnored() {
$this
->config('cdn.settings')
->set('mapping.conditions', [
'extensions' => [
'zip',
],
])
->save();
$expected_mapping = [
'type' => 'simple',
'domain' => 'cdn.example.com',
'conditions' => [
'extensions' => [
'zip',
],
],
];
$cdn_settings = $this
->config('cdn.settings');
$this
->assertSame($expected_mapping, $cdn_settings
->get('mapping'));
$this
->runUpdates();
$cdn_settings = $this
->config('cdn.settings');
$this
->assertSame($expected_mapping, $cdn_settings
->get('mapping'));
}
}