Skip to content
Snippets Groups Projects
Commit 5c6b2e4d authored by Yash Rode's avatar Yash Rode Committed by Ted Bowman
Browse files

Issue #3275991 by yash.rode, tedbow: Write test coverage for the bug fix in #3275311

parent c98d05e3
No related branches found
No related tags found
1 merge request!510Issue #3275991: Write test coverage for the bug fix in #3275311
......@@ -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')
......
......@@ -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);
......
......@@ -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.
......
<?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');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment