Skip to content
Snippets Groups Projects
Commit bd0ef69e authored by omkar podey's avatar omkar podey Committed by Adam G-H
Browse files

Issue #3347267 by omkar.podey, phenaproxima: ComposerMinimumStabilityValidator...

Issue #3347267 by omkar.podey, phenaproxima: ComposerMinimumStabilityValidator doesn't check dev packages
parent f629a418
No related branches found
No related tags found
4 merge requests!989Issue #3356804 by phenaproxima: Flag a warning during status check if the...,!800Issue #3347267: ComposerMinimumStabilityValidator doesn't check dev packages,!548Issue #3310729: Incorrect documentation link in UI in case of Process error,!106Issue #3247479: Allow LockFileValidator results to carry multiple messages, and improve their text
...@@ -50,7 +50,7 @@ class ExtensionUpdaterTest extends AutomaticUpdatesExtensionsKernelTestBase { ...@@ -50,7 +50,7 @@ class ExtensionUpdaterTest extends AutomaticUpdatesExtensionsKernelTestBase {
'my_module' => '9.8.1', 'my_module' => '9.8.1',
// Use a legacy version number to ensure they are converted to semantic // Use a legacy version number to ensure they are converted to semantic
// version numbers which will work with the drupal.org Composer facade. // version numbers which will work with the drupal.org Composer facade.
'my_dev_module' => '8.x-1.2-alpha1', 'my_dev_module' => '8.x-1.2-alpha1@alpha',
]); ]);
$user = $this->container->get('current_user')->getAccount(); $user = $this->container->get('current_user')->getAccount();
// Rebuild the container to ensure the package versions are persisted. // Rebuild the container to ensure the package versions are persisted.
...@@ -69,7 +69,7 @@ class ExtensionUpdaterTest extends AutomaticUpdatesExtensionsKernelTestBase { ...@@ -69,7 +69,7 @@ class ExtensionUpdaterTest extends AutomaticUpdatesExtensionsKernelTestBase {
'drupal/my_module' => '9.8.1', 'drupal/my_module' => '9.8.1',
], ],
'dev' => [ 'dev' => [
'drupal/my_dev_module' => '1.2.0-alpha1', 'drupal/my_dev_module' => '1.2.0-alpha1@alpha',
], ],
]; ];
$this->assertSame($expected_versions, $extension_updater->claim($id)->getPackageVersions()); $this->assertSame($expected_versions, $extension_updater->claim($id)->getPackageVersions());
...@@ -93,13 +93,13 @@ class ExtensionUpdaterTest extends AutomaticUpdatesExtensionsKernelTestBase { ...@@ -93,13 +93,13 @@ class ExtensionUpdaterTest extends AutomaticUpdatesExtensionsKernelTestBase {
'require', 'require',
'--dev', '--dev',
'--no-update', '--no-update',
'drupal/my_dev_module:1.2.0-alpha1', 'drupal/my_dev_module:1.2.0-alpha1@alpha',
], ],
[ [
'update', 'update',
'--with-all-dependencies', '--with-all-dependencies',
'drupal/my_module:9.8.1', 'drupal/my_module:9.8.1',
'drupal/my_dev_module:1.2.0-alpha1', 'drupal/my_dev_module:1.2.0-alpha1@alpha',
], ],
]; ];
$extension_updater->stage(); $extension_updater->stage();
......
...@@ -44,7 +44,7 @@ final class ComposerMinimumStabilityValidator implements EventSubscriberInterfac ...@@ -44,7 +44,7 @@ final class ComposerMinimumStabilityValidator implements EventSubscriberInterfac
public function validate(PreRequireEvent $event): void { public function validate(PreRequireEvent $event): void {
$dir = $this->pathLocator->getProjectRoot(); $dir = $this->pathLocator->getProjectRoot();
$minimum_stability = $this->inspector->getConfig('minimum-stability', $dir); $minimum_stability = $this->inspector->getConfig('minimum-stability', $dir);
$requested_packages = $event->getRuntimePackages(); $requested_packages = array_merge($event->getDevPackages(), $event->getRuntimePackages());
foreach ($requested_packages as $package_name => $version) { foreach ($requested_packages as $package_name => $version) {
// In the root composer.json, a stability flag can also be specified. They // In the root composer.json, a stability flag can also be specified. They
......
...@@ -33,9 +33,22 @@ class ComposerMinimumStabilityValidatorTest extends PackageManagerKernelTestBase ...@@ -33,9 +33,22 @@ class ComposerMinimumStabilityValidatorTest extends PackageManagerKernelTestBase
$stage->destroy(); $stage->destroy();
// Specifying a stability flag bypasses this check. // Specifying a stability flag bypasses this check.
$stage1 = $this->createStage(); $stage->create();
$stage1->create(); $stage->require(['drupal/core:9.8.1-beta1@dev']);
$stage1->require(['drupal/core:9.8.1-beta1@dev']); $stage->destroy();
// Dev packages are also checked.
$stage->create();
$result = ValidationResult::createError([
t("<code>drupal/core-dev</code>'s requested version 9.8.x-dev is less stable (dev) than the minimum stability (stable) required in <PROJECT_ROOT>/composer.json."),
]);
try {
$stage->require([], ['drupal/core-dev:9.8.x-dev']);
$this->fail('Able to require a package even though it did not meet minimum stability.');
}
catch (StageEventException $exception) {
$this->assertValidationResultsEqual([$result], $exception->event->getResults());
}
} }
} }
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