diff --git a/core/modules/system/tests/fixtures/update/drupal-8.update-test-semver-update-n-enabled.php b/core/modules/system/tests/fixtures/update/drupal-8.update-test-semver-update-n-enabled.php new file mode 100644 index 0000000000..663360955a --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.update-test-semver-update-n-enabled.php @@ -0,0 +1,38 @@ +merge('key_value') + ->condition('collection', 'system.schema') + ->condition('name', 'update_test_semver_update_n') + ->fields([ + 'collection' => 'system.schema', + 'name' => 'update_test_semver_update_n', + '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']['update_test_semver_update_n'] = 8000; +$connection->update('config') + ->fields([ + 'data' => serialize($extensions), + ]) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute(); diff --git a/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml b/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml new file mode 100644 index 0000000000..8063e099b7 --- /dev/null +++ b/core/modules/system/tests/modules/system_core_semver_test/system_core_semver_test.info.yml @@ -0,0 +1,6 @@ +name: 'System core ^8 version test' +type: module +description: 'Support module for testing core using semver.' +package: Testing +version: 1.0.0 +core: ^8 diff --git a/core/modules/system/tests/modules/system_incompatible_core_version_test_9x/system_incompatible_core_version_test_9x.info.yml b/core/modules/system/tests/modules/system_incompatible_core_version_test_9x/system_incompatible_core_version_test_99x.info.yml similarity index 71% rename from core/modules/system/tests/modules/system_incompatible_core_version_test_9x/system_incompatible_core_version_test_9x.info.yml rename to core/modules/system/tests/modules/system_incompatible_core_version_test_9x/system_incompatible_core_version_test_99x.info.yml index 2f9f9d5750..449c61b3ce 100644 --- a/core/modules/system/tests/modules/system_incompatible_core_version_test_9x/system_incompatible_core_version_test_9x.info.yml +++ b/core/modules/system/tests/modules/system_incompatible_core_version_test_9x/system_incompatible_core_version_test_99x.info.yml @@ -1,4 +1,4 @@ -name: 'System incompatible core 9.x version test' +name: 'System incompatible core 99.x version test' type: module description: 'Support module for testing system core incompatibility.' package: Testing diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module index e0825d2993..e90b54a85b 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -75,7 +75,7 @@ function system_test_system_info_alter(&$info, Extension $file, $type) { 'system_incompatible_core_version_dependencies_test', 'system_incompatible_module_version_test', 'system_incompatible_core_version_test', - 'system_incompatible_core_version_test_9x', + 'system_incompatible_core_version_test_99x', ])) { $info['hidden'] = FALSE; } diff --git a/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml b/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml new file mode 100644 index 0000000000..5465a62d0a --- /dev/null +++ b/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.info.yml @@ -0,0 +1,6 @@ +name: 'Update test hook_update_n semver' +type: module +description: 'Support module for update testing with core semver value.' +package: Testing +version: VERSION +core: ^8 diff --git a/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.install b/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.install new file mode 100644 index 0000000000..2f240eeb01 --- /dev/null +++ b/core/modules/system/tests/modules/update_test_semver_update_n/update_test_semver_update_n.install @@ -0,0 +1,17 @@ +set('update_test_semver_update_n_update_8001', 'Yes, I was run. Thanks for testing!'); +} diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php index d5b0a78ee8..58979081c0 100644 --- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php +++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php @@ -115,7 +115,7 @@ public function testCoreVersionDependency() { // Test the next minor release. \Drupal::state()->set('dependency_test.core_version_requirement', "~$major.$next_minor"); $this->drupalGet('admin/modules'); - $assert_session->fieldDisabled('modules[system_incompatible_core_version_test_9x][enable]'); + $assert_session->fieldDisabled('modules[system_incompatible_core_version_test_99x][enable]'); $assert_session->fieldDisabled('modules[common_test][enable]'); // Test either current major or the next one. @@ -137,11 +137,13 @@ public function testCoreVersionDependency() { \Drupal::state()->set('dependency_test.core_version_requirement', "~$major.$minor"); $this->drupalGet('admin/modules'); $this->assertFalse($assert_session->elementExists('css', '[name="modules[common_test][enable]"]')->hasAttribute('disabled')); + $this->assertFalse($assert_session->elementExists('css', '[name="modules[system_core_semver_test][enable]"]')->hasAttribute('disabled')); - // Ensure the module can actually be installed. + // Ensure the modules can actually be installed. $edit['modules[common_test][enable]'] = 'common_test'; + $edit['modules[system_core_semver_test][enable]'] = 'system_core_semver_test'; $this->drupalPostForm('admin/modules', $edit, t('Install')); - $this->assertModules(['common_test'], TRUE); + $this->assertModules(['common_test', 'system_core_semver_test'], TRUE); } /** diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php index 02952f6656..0c6934624f 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -367,8 +367,11 @@ public function testInvalidTheme() { $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => 'not_real_test_basetheme'])); $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => 'test_invalid_basetheme'])); $this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', ['@theme_engine' => 'not_real_engine'])); - // Check for the error text of a theme with the wrong core version. - $this->assertText("This theme is not compatible with Drupal " . \Drupal::VERSION . ". Check that the .info.yml file contains a compatible 'core' value."); + // Check for the error text of a theme with the wrong core version + // using 7.x and ^7. + $incompatible_core_message = 'This theme is not compatible with Drupal ' . \Drupal::VERSION . ". Check that the .info.yml file contains a compatible 'core' value."; + $this->assertThemeIncompatibleText('Theme test with invalid core version 8.8.0-dev', $incompatible_core_message); + $this->assertThemeIncompatibleText('Theme test with invalid semver core version', $incompatible_core_message); // Check for the error text of a theme without a content region. $this->assertText("This theme is missing a 'content' region."); } @@ -437,24 +440,29 @@ public function testUninstallingThemes() { * Tests installing a theme and setting it as default. */ public function testInstallAndSetAsDefault() { - $this->drupalGet('admin/appearance'); - // Bartik is uninstalled in the test profile and has the third "Install and - // set as default" link. - $this->clickLink(t('Install and set as default'), 2); - // Test the confirmation message. - $this->assertText('Bartik is now the default theme.'); - // Make sure Bartik is now set as the default theme in config. - $this->assertEqual($this->config('system.theme')->get('default'), 'bartik'); - - // This checks for a regression. See https://www.drupal.org/node/2498691. - $this->assertNoText('The bartik theme was not found.'); - - $themes = \Drupal::service('theme_handler')->rebuildThemeData(); - $version = $themes['bartik']->info['version']; + $themes = [ + 'bartik' => 'Bartik', + 'test_core_semver' => 'Theme test with semver core version', + ]; + foreach ($themes as $theme_machine_name => $theme_name) { + $this->drupalGet('admin/appearance'); + $this->getSession()->getPage()->findLink("Install $theme_name as default theme")->click(); + // Test the confirmation message. + $this->assertText("$theme_name is now the default theme."); + // Make sure Bartik is now set as the default theme in config. + $this->assertEqual($this->config('system.theme')->get('default'), $theme_machine_name); + + // This checks for a regression. See https://www.drupal.org/node/2498691. + $this->assertNoText("The $theme_machine_name theme was not found."); + + $themes = \Drupal::service('theme_handler')->rebuildThemeData(); + $version = $themes[$theme_machine_name]->info['version']; + + // Confirm Bartik is indicated as the default theme. + $out = $this->getSession()->getPage()->getContent(); + $this->assertTrue((bool) preg_match("/$theme_name " . preg_quote($version) . '\s{2,}\(default theme\)/', $out)); + } - // Confirm Bartik is indicated as the default theme. - $out = $this->getSession()->getPage()->getContent(); - $this->assertTrue((bool) preg_match('/Bartik ' . preg_quote($version) . '\s{2,}\(default theme\)/', $out)); } /** @@ -470,4 +478,8 @@ public function testThemeSettingsNoLogoNoFavicon() { $this->assertText('The configuration options have been saved.'); } + private function assertThemeIncompatibleText($theme_name, $expected_text) { + $this->assertSession()->elementExists('css', ".theme-info:contains(\"$theme_name\") .incompatible:contains(\"$expected_text\")"); + } + } diff --git a/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml b/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml new file mode 100644 index 0000000000..2ba1eb76e9 --- /dev/null +++ b/core/modules/system/tests/themes/test_core_semver/test_core_semver.info.yml @@ -0,0 +1,5 @@ +name: 'Theme test with semver core version' +type: theme +description: 'Test theme which has semver core version.' +version: VERSION +core: ^8 || ^9 diff --git a/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml b/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml new file mode 100644 index 0000000000..f349cfc0f9 --- /dev/null +++ b/core/modules/system/tests/themes/test_invalid_core_semver/test_invalid_core_semver.info.yml @@ -0,0 +1,5 @@ +name: 'Theme test with invalid semver core version' +type: theme +description: 'Test theme which has an invalid semver core version.' +version: VERSION +core: ^7 diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php index 942cb886ad..504eb96ab9 100644 --- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php @@ -26,6 +26,7 @@ protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz', __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php', + __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-8.update-test-semver-update-n-enabled.php', ]; } @@ -99,8 +100,11 @@ public function testUpdateHookN() { // Ensure schema has changed. $this->assertEqual(drupal_get_installed_schema_version('update_test_schema', TRUE), 8001); + $this->assertEqual(drupal_get_installed_schema_version('update_test_semver_update_n', TRUE), 8001); // Ensure the index was added for column a. $this->assertTrue($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.'); + // Ensure update_test_semver_update_n_update_8001 was run. + $this->assertEquals(\Drupal::state()->get('update_test_semver_update_n_update_8001'), 'Yes, I was run. Thanks for testing!'); } /**