diff --git a/package_manager/src/Validator/ComposerExecutableValidator.php b/package_manager/src/Validator/ComposerExecutableValidator.php index 959703f55b2728c940438c1894828e0a9115bae9..6b6914e65a946211a11e44cfba2ed9716c33b2e8 100644 --- a/package_manager/src/Validator/ComposerExecutableValidator.php +++ b/package_manager/src/Validator/ComposerExecutableValidator.php @@ -99,7 +99,7 @@ class ComposerExecutableValidator implements EventSubscriberInterface { /** * Flags a validation error. * - * @param string $message + * @param string|\Drupal\Core\StringTranslation\TranslatableMarkup $message * The error message. If the Help module is enabled, a link to Package * Manager's online documentation will be appended. * @param \Drupal\package_manager\Event\PreOperationStageEvent $event @@ -107,7 +107,7 @@ class ComposerExecutableValidator implements EventSubscriberInterface { * * @see package_manager_help() */ - protected function setError(string $message, PreOperationStageEvent $event): void { + protected function setError($message, PreOperationStageEvent $event): void { if ($this->moduleHandler->moduleExists('help')) { $url = Url::fromRoute('help.page', ['name' => 'package_manager']) ->setOption('fragment', 'package-manager-faq-composer-not-found') diff --git a/package_manager/tests/src/Kernel/ComposerExecutableValidatorTest.php b/package_manager/tests/src/Kernel/ComposerExecutableValidatorTest.php index bea65d091bf8aad3ac41830d2c3bc199f4699f52..d32e355b4fed790abe134e4a2eb958865b99cabc 100644 --- a/package_manager/tests/src/Kernel/ComposerExecutableValidatorTest.php +++ b/package_manager/tests/src/Kernel/ComposerExecutableValidatorTest.php @@ -173,11 +173,7 @@ class ComposerExecutableValidatorTest extends PackageManagerKernelTestBase { return $message . ' See <a href="' . $url . '">the help page</a> for information on how to configure the path to Composer.'; }; foreach ($expected_results as $index => $result) { - // The original messages contain HTML, so they need to be properly escaped - // before they are modified, to ensure that they are accurately compared - // with the messages returned by the validator. - $messages = array_map('\Drupal\Component\Utility\Html::escape', $result->getMessages()); - $messages = array_map($map, $messages); + $messages = array_map($map, $result->getMessages()); $expected_results[$index] = ValidationResult::createError($messages); } $this->assertStatusCheckResults($expected_results); diff --git a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php index 97cc989455ec61ba97f8e25f4d2f38f083ade443..0703c6482484be892d80f0754e78f36f7277007c 100644 --- a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php +++ b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php @@ -35,6 +35,7 @@ abstract class AutomaticUpdatesFunctionalTestBase extends BrowserTestBase { // server. This should be okay in most situations because, apart from the // validator, only Composer Stager needs run Composer, and // package_manager_bypass is disabling those operations. + // @todo https://www.drupal.org/project/automatic_updates/issues/3320755. 'automatic_updates.composer_executable_validator', 'package_manager.validator.composer_executable', // Always allow tests to run with Xdebug on. diff --git a/tests/src/Functional/ClickableHelpTest.php b/tests/src/Functional/ClickableHelpTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0a8764acc04120c7e6b421ba15caf5f597f0acc0 --- /dev/null +++ b/tests/src/Functional/ClickableHelpTest.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\Tests\automatic_updates\Functional; + +/** + * Tests package manager help link is clickable. + * + * @group automatic_updates + */ +class ClickableHelpTest extends AutomaticUpdatesFunctionalTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'automatic_updates', + 'help', + ]; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'starterkit_theme'; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + unset($this->disableValidators[array_search('package_manager.validator.composer_executable', $this->disableValidators)]); + parent::setUp(); + $this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml'); + $this->checkerRunnerUser = $this->createUser([ + 'administer site configuration', + ]); + } + + /** + * Tests if composer executable is not present then the help link clickable. + */ + public function testHelpLinkClickable(): void { + $this->drupalLogin($this->checkerRunnerUser); + $this->config('package_manager.settings') + ->set('executables.composer', '/not/matching/path/to/composer') + ->save(); + $this->drupalGet('admin/reports/status'); + $this->assertSession()->linkByHrefExists('/admin/help/package_manager#package-manager-faq-composer-not-found'); + } + +}