Skip to content
Snippets Groups Projects
Commit c52e9ab3 authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3344689 by tedbow: Do not disable package_manager.validator.composer

parent 24ce450a
No related branches found
No related tags found
No related merge requests found
name: 'Automatic Updates Test - Disable validators'
type: module
description: 'Provides a mechanism to disable specific validators during functional tests'
package: Testing
<?php
declare(strict_types = 1);
namespace Drupal\automatic_updates_test_disable_validators;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\Core\Site\Settings;
/**
* Disables specific validators in the service container.
*/
class AutomaticUpdatesTestDisableValidatorsServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container): void {
parent::alter($container);
$validators = Settings::get('automatic_updates_test_disable_validators', []);
array_walk($validators, [$container, 'removeDefinition']);
}
}
......@@ -5,7 +5,6 @@ declare(strict_types = 1);
namespace Drupal\Tests\automatic_updates\Functional;
use Drupal\automatic_updates\CronUpdater;
use Drupal\Core\Site\Settings;
use Drupal\fixture_manipulator\StageFixtureManipulator;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait;
......@@ -29,31 +28,14 @@ abstract class AutomaticUpdatesFunctionalTestBase extends BrowserTestBase {
*/
protected static $modules = [
'automatic_updates',
'automatic_updates_test_disable_validators',
'package_manager_bypass',
];
/**
* The service IDs of any validators to disable.
*
* @var string[]
*/
protected $disableValidators = [
// Disable the Composer executable validator, since it may cause the tests
// to fail if a supported version of Composer is unavailable to the web
// server. This should be okay in most situations because, apart from the
// validator, only Composer Stager needs run Composer, and
// package_manager_bypass is disabling those operations.
// @todo https://www.drupal.org/project/automatic_updates/issues/3320755.
'package_manager.validator.composer_executable',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->disableValidators($this->disableValidators);
$this->useFixtureDirectoryAsActive(__DIR__ . '/../../../package_manager/tests/fixtures/fake_site');
// @todo Remove in https://www.drupal.org/project/automatic_updates/issues/3284443
$this->config('automatic_updates.settings')->set('cron', CronUpdater::SECURITY)->save();
......@@ -93,36 +75,6 @@ abstract class AutomaticUpdatesFunctionalTestBase extends BrowserTestBase {
parent::tearDown();
}
/**
* Disables validators in the test site's settings.
*
* This modifies the service container such that the disabled validators are
* not defined at all. This method will have no effect unless the
* automatic_updates_test_disable_validators module is installed.
*
* @param string[] $validators
* The service IDs of the validators to disable.
*
* @see \Drupal\automatic_updates_test_disable_validators\AutomaticUpdatesTestDisableValidatorsServiceProvider::alter()
*/
protected function disableValidators(array $validators): void {
$key = 'automatic_updates_test_disable_validators';
$disabled_validators = Settings::get($key, []);
foreach ($validators as $service_id) {
$disabled_validators[] = $service_id;
}
$this->writeSettings([
'settings' => [
$key => (object) [
'value' => $disabled_validators,
'required' => TRUE,
],
],
]);
$this->rebuildContainer();
}
/**
* Mocks the current (running) version of core, as known to the Update module.
*
......
......@@ -25,15 +25,6 @@ class ClickableHelpTest extends AutomaticUpdatesFunctionalTestBase {
*/
protected $defaultTheme = 'starterkit_theme';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
unset($this->disableValidators[array_search('package_manager.validator.composer_executable', $this->disableValidators)]);
parent::setUp();
$this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml');
}
/**
* Tests if composer executable is not present then the help link clickable.
*/
......
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