function PhpTufValidatorTest::testInvalidConfigurationInStage
Tests errors caused by invalid plugin configuration in the stage directory.
@dataProvider providerInvalidConfigurationInStage
Parameters
array $config: The Composer configuration to set.
\Drupal\Core\StringTranslation\TranslatableMarkup[] $expected_messages: The expected error messages.
string $event_class: The event before which the plugin's configuration should be changed.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PhpTufValidatorTest.php, line 218
Class
- PhpTufValidatorTest
- @coversDefaultClass \Drupal\package_manager\Validator\PhpTufValidator @group package_manager @group #slow @internal
Namespace
Drupal\Tests\package_manager\KernelCode
public function testInvalidConfigurationInStage(array $config, array $expected_messages, string $event_class) : void {
$listener = function (PreRequireEvent|PreApplyEvent $event) use ($config) : void {
(new FixtureManipulator())->addConfig($config)
->commitChanges($event->stage
->getStageDirectory())
->updateLock();
};
$this->addEventTestListener($listener, $event_class);
// LockFileValidator will complain because we have not added, removed, or
// updated any packages in the stage. In this very specific situation, it's
// okay to disable that validator to remove the interference.
if ($event_class === PreApplyEvent::class) {
$lock_file_validator = $this->container
->get(LockFileValidator::class);
$this->container
->get('event_dispatcher')
->removeSubscriber($lock_file_validator);
}
$result = ValidationResult::createError($expected_messages, $this->t('The stage directory is not protected by PHP-TUF, which is required to use Package Manager securely.'));
$this->assertResults([
$result,
], $event_class);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.