function PhpTufValidatorTest::testPluginRemovedFromStagePreApply
Tests removing the plugin from the stage before applying it.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PhpTufValidatorTest.php, line 108
Class
- PhpTufValidatorTest
- @coversDefaultClass \Drupal\package_manager\Validator\PhpTufValidator @group package_manager @group #slow @internal
Namespace
Drupal\Tests\package_manager\KernelCode
public function testPluginRemovedFromStagePreApply() : void {
$stage = $this->createStage();
$stage->create();
$stage->require([
'ext-json:*',
]);
(new FixtureManipulator())->removePackage(PhpTufValidator::PLUGIN_NAME)
->commitChanges($stage->getStageDirectory());
$messages = [
$this->t('The <code>php-tuf/composer-integration</code> plugin is not installed.'),
// Composer automatically removes the plugin from the `allow-plugins`
// list when the plugin package is removed.
$this->t('The <code>php-tuf/composer-integration</code> plugin is not listed as an allowed plugin.'),
];
$result = ValidationResult::createError($messages, $this->t('The stage directory is not protected by PHP-TUF, which is required to use Package Manager securely.'));
try {
$stage->apply();
$this->fail('Expected an exception but none was thrown.');
} catch (StageEventException $e) {
$this->assertInstanceOf(PreApplyEvent::class, $e->event);
$this->assertValidationResultsEqual([
$result,
], $e->event
->getResults());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.