From 6696dd12bfbc540e2e6c3aa4bce51b6fe47cfcb0 Mon Sep 17 00:00:00 2001 From: "kunal.sachdev" <kunal.sachdev@3685163.no-reply.drupal.org> Date: Thu, 1 Dec 2022 18:13:39 +0000 Subject: [PATCH] Issue #3321386 by kunal.sachdev, tedbow, Wim Leers: Add missing test coverage in SupportedReleaseValidatorTest --- .../package_manager_theme.1.1.xml | 61 +++++++++++++++++++ .../package_manager_theme.info.yml.hide | 1 + .../Kernel/SupportedReleaseValidatorTest.php | 57 +++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 package_manager/tests/fixtures/release-history/package_manager_theme.1.1.xml create mode 100644 package_manager/tests/fixtures/supported_release_validator/active/modules/package_manager_theme/package_manager_theme.info.yml.hide diff --git a/package_manager/tests/fixtures/release-history/package_manager_theme.1.1.xml b/package_manager/tests/fixtures/release-history/package_manager_theme.1.1.xml new file mode 100644 index 0000000000..69779f4ce9 --- /dev/null +++ b/package_manager/tests/fixtures/release-history/package_manager_theme.1.1.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +This fixture is used by \Drupal\Tests\package_manager\Kernel\SupportedReleaseValidatorTest. + +Contains metadata about the following (fake) releases of Package Manager Theme, all of which are secure, in order: +- 8.2.0, which is in an unsupported branch +- 8.1.1 +- 8.1.0 +--> +<project xmlns:dc="http://purl.org/dc/elements/1.1/"> +<title>Package Manager Theme</title> +<short_name>package_manager_theme</short_name> +<dc:creator>Drupal</dc:creator> +<supported_branches>8.0.,8.1.</supported_branches> +<project_status>published</project_status> +<link>http://example.com/project/package_manager_theme</link> + <terms> + <term><name>Projects</name><value>Package Manager Theme project</value></term> + </terms> +<releases> + <release> + <name>Package Manager Theme 8.2.0</name> + <version>8.2.0</version> + <tag>8.2.0</tag> + <status>published</status> + <release_link>http://example.com/package_manager_theme-8-2-0-release</release_link> + <download_link>http://example.com/package_manager_theme-8-2-0.tar.gz</download_link> + <date>1584195300</date> + <terms> + <term><name>Release type</name><value>New features</value></term> + <term><name>Release type</name><value>Bug fixes</value></term> + </terms> + </release> + <release> + <name>Package Manager Theme 8.1.1</name> + <version>8.1.1</version> + <tag>8.1.1</tag> + <status>published</status> + <release_link>http://example.com/package_manager_theme-8-1-1-release</release_link> + <download_link>http://example.com/package_manager_theme-8-1-1.tar.gz</download_link> + <date>1581603300</date> + <terms> + <term><name>Release type</name><value>New features</value></term> + <term><name>Release type</name><value>Bug fixes</value></term> + </terms> + </release> + <release> + <name>Package Manager Theme 8.1.0</name> + <version>8.1.0</version> + <tag>8.1.0</tag> + <status>published</status> + <release_link>http://example.com/package_manager_theme-8-1-0-release</release_link> + <download_link>http://example.com/package_manager_theme-8-1-0.tar.gz</download_link> + <date>1573827300</date> + <terms> + <term><name>Release type</name><value>New features</value></term> + <term><name>Release type</name><value>Bug fixes</value></term> + </terms> + </release> +</releases> +</project> diff --git a/package_manager/tests/fixtures/supported_release_validator/active/modules/package_manager_theme/package_manager_theme.info.yml.hide b/package_manager/tests/fixtures/supported_release_validator/active/modules/package_manager_theme/package_manager_theme.info.yml.hide new file mode 100644 index 0000000000..12fb0ea70f --- /dev/null +++ b/package_manager/tests/fixtures/supported_release_validator/active/modules/package_manager_theme/package_manager_theme.info.yml.hide @@ -0,0 +1 @@ +project: package_manager_theme diff --git a/package_manager/tests/src/Kernel/SupportedReleaseValidatorTest.php b/package_manager/tests/src/Kernel/SupportedReleaseValidatorTest.php index 11e1c00b6e..523241bf82 100644 --- a/package_manager/tests/src/Kernel/SupportedReleaseValidatorTest.php +++ b/package_manager/tests/src/Kernel/SupportedReleaseValidatorTest.php @@ -42,6 +42,18 @@ class SupportedReleaseValidatorTest extends PackageManagerKernelTestBase { 'type' => 'drupal-module', 'install_path' => '../../modules/aaa_update_test', ]); + $this->addPackage($active_dir, [ + 'name' => "drupal/package_manager_theme", + 'version' => '8.1.0', + 'type' => 'drupal-theme', + 'install_path' => '../../modules/package_manager_theme', + ]); + $this->addPackage($active_dir, [ + 'name' => "somewhere/a_drupal_module", + 'version' => '8.1.0', + 'type' => 'drupal-module', + 'install_path' => '../../modules/a_drupal_module', + ]); } /** @@ -145,6 +157,51 @@ class SupportedReleaseValidatorTest extends PackageManagerKernelTestBase { ], [], ], + 'package_manager_theme, supported update' => [ + [ + 'package_manager_theme' => "$release_fixture_folder/package_manager_theme.1.1.xml", + ], + NULL, + TRUE, + [ + 'name' => "drupal/package_manager_theme", + 'version' => '8.1.1', + 'type' => 'drupal-theme', + 'install_path' => NULL, + ], + [], + ], + 'package_manager_theme, update to unsupported branch' => [ + [ + 'package_manager_theme' => "$release_fixture_folder/package_manager_theme.1.1.xml", + ], + NULL, + TRUE, + [ + 'name' => "drupal/package_manager_theme", + 'version' => '8.2.0', + 'type' => 'drupal-theme', + 'install_path' => NULL, + ], + [ + ValidationResult::createError(['package_manager_theme (drupal/package_manager_theme) 8.2.0'], $summary), + ], + ], + // For modules that don't start with 'drupal/' will not have update XML + // from drupal.org and so will not be checked by the validator. + // @see \Drupal\package_manager\Validator\SupportedReleaseValidator::checkStagedReleases() + 'updating a module that does not start with drupal/' => [ + [], + NULL, + TRUE, + [ + 'name' => "somewhere/a_drupal_module", + 'version' => '8.1.1', + 'type' => 'drupal-module', + 'install_path' => NULL, + ], + [], + ], ]; } -- GitLab