diff --git a/tests/fixtures/project_staged_validation/no_core_requirements/vendor/.gitkeep b/tests/fixtures/project_staged_validation/no_core_requirements/vendor/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php b/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php index bc54f88e7718f2fce39f458ceb0ec3a736776c4a..3a0fdb99dc50a58f4f5682f6a93388b935925e6a 100644 --- a/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; use Drupal\package_manager\ValidationResult; -use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\package_manager\PathLocator; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; @@ -22,22 +21,16 @@ class CoreComposerValidatorTest extends AutomaticUpdatesKernelTestBase { 'package_manager', ]; - /** - * {@inheritdoc} - */ - public function register(ContainerBuilder $container) { - parent::register($container); - // Disable validators which interfere with the validator under test. - $container->removeDefinition('automatic_updates.disk_space_validator'); - } - /** * Tests that an error is raised if core is not required in composer.json. */ public function testCoreNotRequired(): void { // Point to a valid composer.json with no requirements. + $active_dir = __DIR__ . '/../../../fixtures/project_staged_validation/no_core_requirements'; $locator = $this->prophesize(PathLocator::class); - $locator->getActiveDirectory()->willReturn(__DIR__ . '/../../../fixtures/project_staged_validation/no_core_requirements'); + $locator->getActiveDirectory()->willReturn($active_dir); + $locator->getProjectRoot()->willReturn($active_dir); + $locator->getVendorDirectory()->willReturn($active_dir . '/vendor'); $this->container->set('package_manager.path_locator', $locator->reveal()); $error = ValidationResult::createError([ diff --git a/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php b/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php index 82e0feed52c6b25cac982ec343603ed547d84c64..21d7a1d0b36cb79ef1a254357a54ad9bebe5a9bd 100644 --- a/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/StagedProjectsValidatorTest.php @@ -3,8 +3,8 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\package_manager\Event\PreApplyEvent; use Drupal\package_manager\PathLocator; +use Drupal\package_manager\StageException; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; /** @@ -50,12 +50,17 @@ class StagedProjectsValidatorTest extends AutomaticUpdatesKernelTestBase { $locator->getStageDirectory()->willReturn($stage_dir); $this->container->set('package_manager.path_locator', $locator->reveal()); - $event = new PreApplyEvent( - $this->container->get('automatic_updates.updater') - ); - - $this->container->get('event_dispatcher')->dispatch($event); - return $event->getResults(); + // The staged projects validator only runs before staged updates are + // applied. Since the active and stage directories may not exist, we don't + // want to invoke the other stages of the update because they may raise + // errors that are outside of the scope of what we're testing here. + try { + $this->container->get('automatic_updates.updater')->apply(); + return []; + } + catch (StageException $e) { + return $e->getResults(); + } } /**