diff --git a/automatic_updates_extensions/src/Form/UpdaterForm.php b/automatic_updates_extensions/src/Form/UpdaterForm.php index b2d3a5d90185b793bf1e715c13c83de14fb6f3ef..d7e6545d2e0aec0e2498c4b2c446b05264beffea 100644 --- a/automatic_updates_extensions/src/Form/UpdaterForm.php +++ b/automatic_updates_extensions/src/Form/UpdaterForm.php @@ -232,6 +232,9 @@ final class UpdaterForm extends FormBase { * Modules that require updates. */ private function getRecommendedModuleUpdates(): array { + $supported_project_types = [ + "module", "module-disabled", "theme", "theme-disabled", + ]; $available_updates = update_get_available(TRUE); if (empty($available_updates)) { $this->messenger()->addError('There was a problem getting update information. Try again later.'); @@ -243,7 +246,7 @@ final class UpdaterForm extends FormBase { $installed_packages = array_keys($this->extensionUpdater->getActiveComposer()->getInstalledPackages()); $non_supported_update_statuses = []; foreach ($project_data as $project_name => $project_info) { - if ($project_info['project_type'] === 'module' || $project_info['project_type'] === 'module-disabled') { + if (in_array($project_info['project_type'], $supported_project_types, TRUE)) { if ($project_info['status'] !== UpdateManagerInterface::CURRENT) { if (!in_array("drupal/$project_name", $installed_packages, TRUE)) { $non_supported_update_statuses[] = $project_info['status']; diff --git a/automatic_updates_extensions/tests/fixtures/active_composer/two_projects/vendor/composer/installed.json b/automatic_updates_extensions/tests/fixtures/active_composer/two_projects/vendor/composer/installed.json index 388864cbdafd88772ef70e5da434326c8aa34c9e..81dc1c71b04f960bce36c88bdc2b5f791156491e 100644 --- a/automatic_updates_extensions/tests/fixtures/active_composer/two_projects/vendor/composer/installed.json +++ b/automatic_updates_extensions/tests/fixtures/active_composer/two_projects/vendor/composer/installed.json @@ -19,6 +19,11 @@ "name": "drupal/aaa_update_test", "version": "9.8.1", "type": "drupal-module" + }, + { + "name": "drupal/test_theme", + "version": "9.8.1", + "type": "drupal-theme" } ] } diff --git a/automatic_updates_extensions/tests/fixtures/release-history/test_theme.1.1.xml b/automatic_updates_extensions/tests/fixtures/release-history/test_theme.1.1.xml new file mode 100644 index 0000000000000000000000000000000000000000..536072afa2506e511c5670a99a10b891dfde9204 --- /dev/null +++ b/automatic_updates_extensions/tests/fixtures/release-history/test_theme.1.1.xml @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="utf-8"?> +<project xmlns:dc="http://purl.org/dc/elements/1.1/"> + <title>Test theme</title> + <short_name>test_theme</short_name> + <dc:creator>drupal</dc:creator> + <type>project_theme</type> + <supported_branches>8.x-2.,3.0.</supported_branches> + <project_status>published</project_status> + <link>http://example.com/project/test_theme</link> + <terms> + <term> + <name>Projects</name> + <value>Themes</value> + </term> + <term> + <name>Maintenance status</name> + <value>Minimally maintained</value> + </term> + <term> + <name>Development status</name> + <value>Under active development</value> + </term> + </terms> + <releases> + <release> + <name>test_theme 3.0.0</name> + <version>3.0.0</version> + <tag>3.0.0</tag> + <status>published</status> + <release_link>http://example.com/test_theme/releases/3.0.0</release_link> + <download_link>http://example.com/test_theme-3.0.0.tar.gz</download_link> + <date>1597793786</date> + <files> + <file> + <url>http://example.com/test_theme-3.0.0.tar.gz</url> + <archive_type>tar.gz</archive_type> + <md5>43956be126b27d718ecffd0b17244aa1</md5> + <size>196080</size> + <filedate>1597793786</filedate> + </file> + <file> + <url>http://example.com/test_theme-3.0.0.zip</url> + <archive_type>zip</archive_type> + <md5>5d24ec88ac4755af6ccbe6ef5ff8b3c9</md5> + <size>200399</size> + <filedate>1597793786</filedate> + </file> + </files> + <security covered="1">Covered by Drupal's security advisory policy</security> + <core_compatibility>^8 || ^9</core_compatibility> + </release> + <release> + <name>test_theme 8.x-2.1</name> + <version>8.x-2.1</version> + <tag>8.x-2.1</tag> + <status>published</status> + <release_link>http://example.com/test_theme/releases/8.x-2.1</release_link> + <download_link>http://example.com/test_theme-8.x-2.1.tar.gz</download_link> + <date>1597793786</date> + <files> + <file> + <url>http://example.com/test_theme-8.x-2.1.tar.gz</url> + <archive_type>tar.gz</archive_type> + <md5>43956be126b27d718ecffd0b17244aa1</md5> + <size>196080</size> + <filedate>1597793786</filedate> + </file> + <file> + <url>http://example.com/test_theme-8.x-2.1.zip</url> + <archive_type>zip</archive_type> + <md5>5d24ec88ac4755af6ccbe6ef5ff8b3c9</md5> + <size>200399</size> + <filedate>1597793786</filedate> + </file> + </files> + <terms> + <term> + <name>Release type</name> + <value>Bug fixes</value> + </term> + </terms> + <security covered="1">Covered by Drupal's security advisory policy</security> + <core_compatibility>8.x</core_compatibility> + </release> + <release> + <name>test_theme 8.x-2.0</name> + <version>8.x-2.0</version> + <tag>8.x-2.0</tag> + <status>published</status> + <release_link>http://example.com/test_theme/releases/8.x-2.0</release_link> + <download_link>http://example.com/test_theme-8.x-2.0.tar.gz</download_link> + <date>1597793786</date> + <files> + <file> + <url>http://example.com/test_theme-8.x-2.0.tar.gz</url> + <archive_type>tar.gz</archive_type> + <md5>43956be126b27d718ecffd0b17244aa1</md5> + <size>196080</size> + <filedate>1597793786</filedate> + </file> + <file> + <url>http://example.com/test_theme-8.x-2.0.zip</url> + <archive_type>zip</archive_type> + <md5>5d24ec88ac4755af6ccbe6ef5ff8b3c9</md5> + <size>200399</size> + <filedate>1597793786</filedate> + </file> + </files> + <terms> + <term> + <name>Release type</name> + <value>Bug fixes</value> + </term> + </terms> + <security covered="1">Covered by Drupal's security advisory policy</security> + <core_compatibility>8.x</core_compatibility> + </release> + </releases> +</project> diff --git a/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php b/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php index f063178b3192418b74c8a1788ae76ff07266adc3..5e47f55a6cb03fecedacc3adec8c79c2e6c6415e 100644 --- a/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php +++ b/automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php @@ -49,8 +49,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { */ public function providerSuccessfulUpdate(): array { return [ - 'maintenance mode on, semver' => [TRUE, 'semver_test', '8.1.0', '8.1.1'], - 'maintenance mode off, legacy' => [FALSE, 'aaa_update_test', '8.x-2.0', '8.x-2.1'], + 'maintenance mode on, semver module' => [ + TRUE, 'semver_test', 'Semver Test', '8.1.0', '8.1.1', + ], + 'maintenance mode off, legacy module' => [ + FALSE, 'aaa_update_test', 'AAA Update test', '8.x-2.0', '8.x-2.1', + ], + 'maintenance mode off, legacy theme' => [ + FALSE, 'test_theme', 'Test theme', '8.x-2.0', '8.x-2.1', + ], ]; } @@ -134,6 +141,8 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * Whether maintenance should be on at the beginning of the update. * @param string $project_name * The project name. + * @param string $project_title + * The project title. * @param string $installed_version * The installed version. * @param string $target_version @@ -141,9 +150,13 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * * @dataProvider providerSuccessfulUpdate */ - public function testSuccessfulUpdate(bool $maintenance_mode_on, string $project_name, string $installed_version, string $target_version): void { + public function testSuccessfulUpdate(bool $maintenance_mode_on, string $project_name, string $project_title, string $installed_version, string $target_version): void { $this->container->get('theme_installer')->install(['automatic_updates_theme_with_updates']); $this->updateProject = $project_name; + // By default, the Update module only checks for updates of installed modules + // and themes. The two modules we're testing here (semver_test and aaa_update_test) + // are already installed by static::$modules. + $this->container->get('theme_installer')->install(['test_theme']); $this->setReleaseMetadata(__DIR__ . '/../../../../tests/fixtures/release-history/drupal.9.8.2.xml'); $this->setReleaseMetadata(__DIR__ . "/../../fixtures/release-history/$project_name.1.1.xml"); $this->setProjectInstalledVersion([$project_name => $installed_version]); @@ -159,7 +172,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $this->drupalGet('/admin/reports/updates'); $this->clickLink('Update Extensions'); $this->assertTableShowsUpdates( - $project_name === 'semver_test' ? 'Semver Test' : 'AAA Update test', + $project_title, $installed_version, $target_version ); diff --git a/automatic_updates_extensions/tests/themes/test_theme/test_theme.info.yml b/automatic_updates_extensions/tests/themes/test_theme/test_theme.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..9fcdf5f644f3cf1e4fb0da1df8a1734bb5e3c44d --- /dev/null +++ b/automatic_updates_extensions/tests/themes/test_theme/test_theme.info.yml @@ -0,0 +1,11 @@ +name: Test theme +type: theme +package: Testing +description: 'A test theme.' +core_version_requirement: ^8 || ^9 +base theme: false +regions: + header: 'Header' + content: 'Content' + sidebar_first: 'Sidebar first' + footer: 'Footer'