Skip to content
Snippets Groups Projects
Commit 670763a4 authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3296178 by kunal.sachdev: Remove TestExtensionUpdater and use new...

Issue #3296178 by kunal.sachdev: Remove TestExtensionUpdater and use new functionality in package_manager_bypass
parent 0b631e97
No related branches found
No related tags found
No related merge requests found
Showing
with 58 additions and 60 deletions
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
}
]
}
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/semver_test",
"version": "9.8.1"
}
]
}
{
"packages": [
{
"name": "drupal/core-recommended",
"version": "9.8.0",
"require": {
"drupal/core": "9.8.0"
}
},
{
"name": "drupal/semver_test",
"version": "9.8.1"
},
{
"name": "drupal/aaa_update_test",
"version": "9.8.1"
}
]
}
name: 'Automatic Updates Extensions Test'
description: 'Automatic Updates Extensions Test module'
type: module
package: Testing
dependencies:
- automatic_updates:automatic_updates_extensions
<?php
namespace Drupal\automatic_updates_extensions_test;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
/**
* Service provider to use test updater service.
*/
class AutomaticUpdatesExtensionsTestServiceProvider implements ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
if ($container->hasDefinition('automatic_updates_extensions.updater')) {
$container->getDefinition('automatic_updates_extensions.updater')
->setClass(TestExtensionUpdater::class);
}
}
}
<?php
namespace Drupal\automatic_updates_extensions_test;
use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\package_manager\ComposerUtility;
/**
* Extends the updater to point to a fixture directory for the active Composer.
*/
class TestExtensionUpdater extends ExtensionUpdater {
/**
* {@inheritdoc}
*/
public function getActiveComposer(): ComposerUtility {
if ($path = \Drupal::state()->get('automatic_updates_extensions_test.active_path')) {
return ComposerUtility::createForDirectory($path);
}
return parent::getActiveComposer();
}
}
......@@ -35,7 +35,6 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
protected static $modules = [
'automatic_updates_test',
'automatic_updates_extensions',
'automatic_updates_extensions_test',
'block',
'semver_test',
'aaa_update_test',
......@@ -78,7 +77,10 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
]);
// We need this fixture as only projects installed via composer will show up
// on the form.
$this->container->get('state')->set('automatic_updates_extensions_test.active_path', __DIR__ . '/../../fixtures/active_composer/two_projects');
$fixture_dir = __DIR__ . '/../../fixtures/two_projects';
Beginner::setFixturePath($fixture_dir);
$this->container->get('package_manager.path_locator')
->setPaths($fixture_dir, $fixture_dir . '/vendor', '');
$this->drupalLogin($user);
$this->drupalPlaceBlock('local_tasks_block', ['primary' => TRUE]);
}
......@@ -163,8 +165,6 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$this->checkForUpdates();
$state = $this->container->get('state');
$state->set('system.maintenance_mode', $maintenance_mode_on);
Beginner::setFixturePath(__DIR__ . '/../../fixtures/fake-site');
StagedDatabaseUpdateValidator::setExtensionsWithUpdates(['system', 'automatic_updates_theme_with_updates']);
$page = $this->getSession()->getPage();
......@@ -216,13 +216,16 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
->save();
$this->setProjectInstalledVersion(
[
'aaa_update_test' => '8.x-2.x',
'aaa_update_test' => '8.x-2.0',
'semver_test' => '8.1.0',
]
);
// One module not installed through composer.
$this->container->get('state')->set('automatic_updates_extensions_test.active_path', __DIR__ . '/../../fixtures/active_composer/one_project');
$fixture_dir = __DIR__ . '/../../fixtures/one_project';
Beginner::setFixturePath($fixture_dir);
$this->container->get('package_manager.path_locator')
->setPaths($fixture_dir, $fixture_dir . '/vendor', '');
$assert = $this->assertSession();
$user = $this->createUser(
[
......@@ -237,7 +240,10 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1');
// Both of the modules not installed through composer.
$this->container->get('state')->set('automatic_updates_extensions_test.active_path', __DIR__ . '/../../fixtures/active_composer/no_project');
$fixture_dir = __DIR__ . '/../../fixtures/no_project';
Beginner::setFixturePath($fixture_dir);
$this->container->get('package_manager.path_locator')
->setPaths($fixture_dir, $fixture_dir . '/vendor', '');
$this->getSession()->reload();
$assert->pageTextContains('Updates were found, but they must be performed manually. See the list of available updates for more information.');
$this->assertNoUpdates();
......
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