Skip to content
Snippets Groups Projects
Commit 52f22acd authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Ted Bowman
Browse files

Issue #3295965 by kunal.sachdev, tedbow, phenaproxima: Add validation that...

Issue #3295965 by kunal.sachdev, tedbow, phenaproxima: Add validation that $projects cannot be an empty array in \Drupal\automatic_updates_extensions\ExtensionUpdater::begin
parent cf911a46
No related branches found
No related tags found
No related merge requests found
...@@ -27,9 +27,12 @@ class ExtensionUpdater extends Stage { ...@@ -27,9 +27,12 @@ class ExtensionUpdater extends Stage {
* The unique ID of the stage. * The unique ID of the stage.
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* Thrown if no project version for Drupal core is provided. * Thrown if no project version is provided.
*/ */
public function begin(array $project_versions): string { public function begin(array $project_versions): string {
if (empty($project_versions)) {
throw new \InvalidArgumentException("No projects to begin the update");
}
$composer = $this->getActiveComposer(); $composer = $this->getActiveComposer();
$package_versions = [ $package_versions = [
'production' => [], 'production' => [],
......
...@@ -114,4 +114,13 @@ class ExtensionUpdaterTest extends AutomaticUpdatesKernelTestBase { ...@@ -114,4 +114,13 @@ class ExtensionUpdaterTest extends AutomaticUpdatesKernelTestBase {
} }
} }
/**
* Tests that an exception is thrown when calling begin() with no projects.
*/
public function testNoProjectsInBegin(): void {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('No projects to begin the update');
$this->container->get('automatic_updates_extensions.updater')->begin([]);
}
} }
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