From c52e9ab30ee7d1350757cb8e37ccc7f96bd59872 Mon Sep 17 00:00:00 2001
From: Ted Bowman <41201-tedbow@users.noreply.drupalcode.org>
Date: Mon, 27 Feb 2023 13:55:50 +0000
Subject: [PATCH] Issue #3344689 by tedbow: Do not disable
 package_manager.validator.composer

---
 ...c_updates_test_disable_validators.info.yml |  4 --
 ...esTestDisableValidatorsServiceProvider.php | 26 ----------
 .../AutomaticUpdatesFunctionalTestBase.php    | 48 -------------------
 tests/src/Functional/ClickableHelpTest.php    |  9 ----
 4 files changed, 87 deletions(-)
 delete mode 100644 tests/modules/automatic_updates_test_disable_validators/automatic_updates_test_disable_validators.info.yml
 delete mode 100644 tests/modules/automatic_updates_test_disable_validators/src/AutomaticUpdatesTestDisableValidatorsServiceProvider.php

diff --git a/tests/modules/automatic_updates_test_disable_validators/automatic_updates_test_disable_validators.info.yml b/tests/modules/automatic_updates_test_disable_validators/automatic_updates_test_disable_validators.info.yml
deleted file mode 100644
index a6587fcc99..0000000000
--- a/tests/modules/automatic_updates_test_disable_validators/automatic_updates_test_disable_validators.info.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-name: 'Automatic Updates Test - Disable validators'
-type: module
-description: 'Provides a mechanism to disable specific validators during functional tests'
-package: Testing
diff --git a/tests/modules/automatic_updates_test_disable_validators/src/AutomaticUpdatesTestDisableValidatorsServiceProvider.php b/tests/modules/automatic_updates_test_disable_validators/src/AutomaticUpdatesTestDisableValidatorsServiceProvider.php
deleted file mode 100644
index 659231eba4..0000000000
--- a/tests/modules/automatic_updates_test_disable_validators/src/AutomaticUpdatesTestDisableValidatorsServiceProvider.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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']);
-  }
-
-}
diff --git a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php
index 46858ebdd4..6416c96e43 100644
--- a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php
+++ b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php
@@ -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.
    *
diff --git a/tests/src/Functional/ClickableHelpTest.php b/tests/src/Functional/ClickableHelpTest.php
index 685855f043..bd5743ad2b 100644
--- a/tests/src/Functional/ClickableHelpTest.php
+++ b/tests/src/Functional/ClickableHelpTest.php
@@ -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.
    */
-- 
GitLab