Skip to content
Snippets Groups Projects
Commit acc33a18 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3248523 by phenaproxima, tedbow: All validation kernel tests should be...

Issue #3248523 by phenaproxima, tedbow: All validation kernel tests should be validating the same way
parent 41d71503
No related branches found
No related tags found
1 merge request!109Issue #3248523: All validation kernel tests should be validating the same way
......@@ -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([
......
......@@ -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();
}
}
/**
......
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