function ComposerPatchesValidatorTest::testErrorDuringPreApplyWithHelp
Tests that validation errors can carry links to help.
@dataProvider providerErrorDuringPreApply
Parameters
int $in_active: Whether patcher is installed in active.
int $in_stage: Whether patcher is installed in stage.
\Drupal\package_manager\ValidationResult[] $expected_results: The expected validation results.
string[] $help_page_sections: An associative array of fragments (anchors) in the online help. The keys should be the numeric indices of the validation result messages which should link to those fragments.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerPatchesValidatorTest.php, line 270
Class
- ComposerPatchesValidatorTest
- @covers \Drupal\package_manager\Validator\ComposerPatchesValidator @group package_manager @internal
Namespace
Drupal\Tests\package_manager\KernelCode
public function testErrorDuringPreApplyWithHelp(int $in_active, int $in_stage, array $expected_results, array $help_page_sections) : void {
$this->enableModules([
'help',
]);
foreach ($expected_results as $result_index => $result) {
$messages = $result->messages;
foreach ($messages as $message_index => $message) {
if ($help_page_sections[$message_index]) {
// Get the link to the online documentation for the error message.
$url = Url::fromRoute('help.page', [
'name' => 'package_manager',
])->setOption('fragment', $help_page_sections[$message_index])
->toString();
// Reformat the provided results so that they all have the link to the
// online documentation appended to them.
$messages[$message_index] = t('@message See <a href=":url">the help page</a> for information on how to resolve the problem.', [
'@message' => $message,
':url' => $url,
]);
}
}
$expected_results[$result_index] = ValidationResult::createError($messages, $result->summary);
}
$this->testErrorDuringPreApply($in_active, $in_stage, $expected_results);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.