diff --git a/automatic_updates_extensions/src/ExtensionUpdater.php b/automatic_updates_extensions/src/ExtensionUpdater.php index 7ee83c8b340218fc194231daf5ff5eb0e5da2bdc..4948ff6133f871f8e4cb70609e1e4504fd7da5e4 100644 --- a/automatic_updates_extensions/src/ExtensionUpdater.php +++ b/automatic_updates_extensions/src/ExtensionUpdater.php @@ -27,9 +27,12 @@ class ExtensionUpdater extends Stage { * The unique ID of the stage. * * @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 { + if (empty($project_versions)) { + throw new \InvalidArgumentException("No projects to begin the update"); + } $composer = $this->getActiveComposer(); $package_versions = [ 'production' => [], diff --git a/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdaterTest.php b/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdaterTest.php index d863afa1b1dd91ebda566544eb559ef27a235778..61f0845de0a71a1ac46465c857a608781990d116 100644 --- a/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdaterTest.php +++ b/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdaterTest.php @@ -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([]); + } + }