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

Contrib: allow uncommetting lines in core MR -...

Contrib: allow uncommetting lines in core MR - project/automatic_updates@11f37000
parent 274e6e2c
No related branches found
No related tags found
No related merge requests found
Pipeline #38580 failed
Pipeline: drupal-3253158

#38581

    ...@@ -1255,4 +1255,4 @@ zzgroup ...@@ -1255,4 +1255,4 @@ zzgroup
    åwesome åwesome
    èxample èxample
    über über
    ȅchȏ ȅchȏ
    \ No newline at end of file
    ...@@ -8,13 +8,11 @@ ...@@ -8,13 +8,11 @@
    use Drupal\auto_updates\CommandExecutor; use Drupal\auto_updates\CommandExecutor;
    use Drupal\auto_updates\UpdateStage; use Drupal\auto_updates\UpdateStage;
    use Drupal\fixture_manipulator\StageFixtureManipulator; use Drupal\fixture_manipulator\StageFixtureManipulator;
    use Drupal\package_manager\PathLocator; use Drupal\Tests\auto_updates\Traits\TestSetUpTrait;
    use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
    use Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait; use Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait;
    use Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait; use Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait;
    use Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait; use Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait;
    use Drupal\Tests\package_manager\Traits\FixtureUtilityTrait;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    /** /**
    * Base class for functional tests of the Automatic Updates module. * Base class for functional tests of the Automatic Updates module.
    ...@@ -26,7 +24,7 @@ abstract class AutoUpdatesFunctionalTestBase extends BrowserTestBase { ...@@ -26,7 +24,7 @@ abstract class AutoUpdatesFunctionalTestBase extends BrowserTestBase {
    use AssertPreconditionsTrait; use AssertPreconditionsTrait;
    use ComposerStagerTestTrait; use ComposerStagerTestTrait;
    use FixtureManipulatorTrait; use FixtureManipulatorTrait;
    use FixtureUtilityTrait; use TestSetUpTrait;
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    ...@@ -41,7 +39,6 @@ abstract class AutoUpdatesFunctionalTestBase extends BrowserTestBase { ...@@ -41,7 +39,6 @@ abstract class AutoUpdatesFunctionalTestBase extends BrowserTestBase {
    */ */
    protected function setUp(): void { protected function setUp(): void {
    parent::setUp(); parent::setUp();
    $this->useFixtureDirectoryAsActive(__DIR__ . '/../../../../package_manager/tests/fixtures/fake_site');
    // @todo Remove in https://www.drupal.org/project/auto_updates/issues/3284443 // @todo Remove in https://www.drupal.org/project/auto_updates/issues/3284443
    $this->config('auto_updates.settings') $this->config('auto_updates.settings')
    ->set('unattended.level', CronUpdateRunner::SECURITY) ->set('unattended.level', CronUpdateRunner::SECURITY)
    ...@@ -49,22 +46,6 @@ protected function setUp(): void { ...@@ -49,22 +46,6 @@ protected function setUp(): void {
    $this->mockActiveCoreVersion('9.8.0'); $this->mockActiveCoreVersion('9.8.0');
    } }
    /**
    * {@inheritdoc}
    */
    protected function installModulesFromClassProperty(ContainerInterface $container): void {
    $container->get('module_installer')->install([
    'package_manager_test_release_history',
    ]);
    $this->container = $container->get('kernel')->getContainer();
    // To prevent tests from making real requests to the Internet, use fake
    // release metadata that exposes a pretend Drupal 9.8.2 release.
    $this->setReleaseMetadata(__DIR__ . '/../../../../package_manager/tests/fixtures/release-history/drupal.9.8.2.xml');
    parent::installModulesFromClassProperty($container);
    }
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    */ */
    ...@@ -98,30 +79,6 @@ protected function mockActiveCoreVersion(string $version): void { ...@@ -98,30 +79,6 @@ protected function mockActiveCoreVersion(string $version): void {
    ->save(); ->save();
    } }
    /**
    * Sets the release metadata file to use when fetching available updates.
    *
    * @todo Remove this function with use of the trait from the Update module in
    * https://drupal.org/i/3348234.
    *
    * @param string $file
    * The path of the XML metadata file to use.
    */
    protected function setReleaseMetadata(string $file): void {
    $this->assertFileIsReadable($file);
    $this->config('update.settings')
    ->set('fetch.url', $this->baseUrl . '/test-release-history')
    ->save();
    [$project] = explode('.', basename($file, '.xml'), 2);
    $xml_map = $this->config('update_test.settings')->get('xml_map') ?? [];
    $xml_map[$project] = $file;
    $this->config('update_test.settings')
    ->set('xml_map', $xml_map)
    ->save();
    }
    /** /**
    * Checks for available updates. * Checks for available updates.
    * *
    ...@@ -147,36 +104,6 @@ protected function assertUpdateReady(string $target_version): void { ...@@ -147,36 +104,6 @@ protected function assertUpdateReady(string $target_version): void {
    $this->assertTrue($button->hasClass('button--primary')); $this->assertTrue($button->hasClass('button--primary'));
    } }
    /**
    * Copies a fixture directory to a temporary directory.
    *
    * @param string $fixture_directory
    * The fixture directory.
    *
    * @return string
    * The temporary directory.
    */
    protected function copyFixtureToTempDirectory(string $fixture_directory): string {
    $temp_directory = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . DIRECTORY_SEPARATOR . $this->randomMachineName(20);
    static::copyFixtureFilesTo($fixture_directory, $temp_directory);
    return $temp_directory;
    }
    /**
    * Sets a fixture directory to use as the active directory.
    *
    * @param string $fixture_directory
    * The fixture directory.
    */
    protected function useFixtureDirectoryAsActive(string $fixture_directory): void {
    // Create a temporary directory from our fixture directory that will be
    // unique for each test run. This will enable changing files in the
    // directory and not affect other tests.
    $active_dir = $this->copyFixtureToTempDirectory($fixture_directory);
    $this->container->get(PathLocator::class)
    ->setPaths($active_dir, $active_dir . '/vendor', '', NULL);
    }
    /** /**
    * Runs the console update command, which will trigger status checks. * Runs the console update command, which will trigger status checks.
    */ */
    ......
    ...@@ -103,10 +103,8 @@ public function testModuleFormInstallDisplay(int $results_severity): void { ...@@ -103,10 +103,8 @@ public function testModuleFormInstallDisplay(int $results_severity): void {
    $page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
    $page->checkField('modules[auto_updates][enable]'); $page->checkField('modules[auto_updates][enable]');
    $page->pressButton('Install'); $page->pressButton('Install');
    if ($page->hasButton('Continue')) { // Confirm installing the experimental module.
    $page->pressButton('Continue'); $page->pressButton('Continue');
    }
    // Cron Updates will always be disabled on installation as per // Cron Updates will always be disabled on installation as per
    // auto_updates.settings.yml . // auto_updates.settings.yml .
    $session = $this->assertSession(); $session = $this->assertSession();
    ......
    ...@@ -45,21 +45,16 @@ protected function setUp(): void { ...@@ -45,21 +45,16 @@ protected function setUp(): void {
    parent::setUp(); parent::setUp();
    $this->setReleaseMetadata(__DIR__ . '/../../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml'); $this->setReleaseMetadata(__DIR__ . '/../../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml');
    $permissions = [ $user = $this->createUser([
    'administer site configuration', 'administer site configuration',
    'administer software updates', 'administer software updates',
    'access administration pages', 'access administration pages',
    'access site in maintenance mode', 'access site in maintenance mode',
    'administer modules', 'administer modules',
    'access site reports', 'access site reports',
    'view update notifications',
    'access help pages', 'access help pages',
    ]; ]);
    // Check for permission that was added in Drupal core 9.4.x.
    $available_permissions = array_keys($this->container->get('user.permissions')->getPermissions());
    if (in_array('view update notifications', $available_permissions, TRUE)) {
    array_push($permissions, 'view update notifications');
    }
    $user = $this->createUser($permissions);
    $this->drupalLogin($user); $this->drupalLogin($user);
    $this->checkForUpdates(); $this->checkForUpdates();
    } }
    ......
    ...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
    use Drupal\auto_updates\CronUpdateRunner; use Drupal\auto_updates\CronUpdateRunner;
    use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
    use Drupal\Tests\auto_updates\Traits\TestSetUpTrait;
    /** /**
    * @group auto_updates * @group auto_updates
    */ */
    class UpdateSettingsFormTest extends WebDriverTestBase { class UpdateSettingsFormTest extends WebDriverTestBase {
    use TestSetUpTrait;
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    */ */
    ......
    <?php
    namespace Drupal\Tests\auto_updates\Traits;
    use Drupal\package_manager\PathLocator;
    use Drupal\Tests\package_manager\Traits\FixtureUtilityTrait;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    /**
    * Common functions to set up tests correctly.
    */
    trait TestSetUpTrait {
    use FixtureUtilityTrait;
    /**
    * {@inheritdoc}
    */
    protected function installModulesFromClassProperty(ContainerInterface $container): void {
    $container->get('module_installer')->install([
    'package_manager_test_release_history',
    'package_manager_bypass',
    ]);
    $this->container = $container->get('kernel')->getContainer();
    // To prevent tests from using the real codebase for Composer we must set
    // the fixture path as early as possible. Automatic Updates will run
    // readiness checks when the module is installed so this must be done before
    // the parent class installs the modules needed for the test.
    $this->useFixtureDirectoryAsActive(__DIR__ . '/../../../../package_manager/tests/fixtures/fake_site');
    // To prevent tests from making real requests to the Internet, use fake
    // release metadata that exposes a pretend Drupal 9.8.2 release.
    $this->setReleaseMetadata(__DIR__ . '/../../../../package_manager/tests/fixtures/release-history/drupal.9.8.2.xml');
    parent::installModulesFromClassProperty($container);
    }
    /**
    * Copies a fixture directory to a temporary directory.
    *
    * @param string $fixture_directory
    * The fixture directory.
    *
    * @return string
    * The temporary directory.
    */
    protected function copyFixtureToTempDirectory(string $fixture_directory): string {
    $temp_directory = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . DIRECTORY_SEPARATOR . $this->randomMachineName(20);
    static::copyFixtureFilesTo($fixture_directory, $temp_directory);
    return $temp_directory;
    }
    /**
    * Sets a fixture directory to use as the active directory.
    *
    * @param string $fixture_directory
    * The fixture directory.
    */
    protected function useFixtureDirectoryAsActive(string $fixture_directory): void {
    // Create a temporary directory from our fixture directory that will be
    // unique for each test run. This will enable changing files in the
    // directory and not affect other tests.
    $active_dir = $this->copyFixtureToTempDirectory($fixture_directory);
    $this->container->get(PathLocator::class)
    ->setPaths($active_dir, $active_dir . '/vendor', '', NULL);
    }
    /**
    * Sets the release metadata file to use when fetching available updates.
    *
    * @todo Remove this function with use of the trait from the Update module in
    * https://drupal.org/i/3348234.
    *
    * @param string $file
    * The path of the XML metadata file to use.
    */
    protected function setReleaseMetadata(string $file): void {
    $this->assertFileIsReadable($file);
    $this->config('update.settings')
    ->set('fetch.url', $this->baseUrl . '/test-release-history')
    ->save();
    [$project] = explode('.', basename($file, '.xml'), 2);
    $xml_map = $this->config('update_test.settings')->get('xml_map') ?? [];
    $xml_map[$project] = $file;
    $this->config('update_test.settings')
    ->set('xml_map', $xml_map)
    ->save();
    }
    }
    ...@@ -328,22 +328,11 @@ public function getInstalledPackagesList(string $working_dir): InstalledPackages ...@@ -328,22 +328,11 @@ public function getInstalledPackagesList(string $working_dir): InstalledPackages
    // same as the working directory, in which case InstalledPackage::$path // same as the working directory, in which case InstalledPackage::$path
    // should be NULL. For all other package types, we consider it invalid // should be NULL. For all other package types, we consider it invalid
    // if the install path is the same as the working directory. // if the install path is the same as the working directory.
    // @todo Remove this handling of metapackage paths when Composer 2.5.7 or
    // later is required, in https://drupal.org/i/3365133.
    if (isset($package['type']) && $package['type'] === 'metapackage') { if (isset($package['type']) && $package['type'] === 'metapackage') {
    // TRICKY: until Composer 2.5.6, metapackages returned the current if ($path !== NULL) {
    // working directory instead of NULL.
    // @see https://github.com/composer/composer/commit/3a48e393756e8b0387925aa327f45a30128b4556
    $packages_data[$name]['path'] = NULL;
    // @todo Remove the if-branch when the minimum Composer version is raised to >=2.5.6.
    if (Semver::satisfies($this->getVersion(), '<2.5.6')) {
    if ($path !== $working_dir) {
    throw new \UnexpectedValueException("Metapackage '$name' is installed at unexpected path: '$path', expected '$working_dir'");
    }
    }
    elseif ($path !== NULL) {
    throw new \UnexpectedValueException("Metapackage '$name' is installed at unexpected path: '$path', expected NULL"); throw new \UnexpectedValueException("Metapackage '$name' is installed at unexpected path: '$path', expected NULL");
    } }
    $packages_data[$name]['path'] = $path;
    } }
    elseif ($path === $working_dir) { elseif ($path === $working_dir) {
    throw new \UnexpectedValueException("Package '$name' cannot be installed at path: '$path'"); throw new \UnexpectedValueException("Package '$name' cannot be installed at path: '$path'");
    ......
    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