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

Issue #3303174 by phenaproxima: Stage should inject the path factory properly

parent 512e19e3
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ services: ...@@ -26,6 +26,7 @@ services:
- '@event_dispatcher' - '@event_dispatcher'
- '@tempstore.shared' - '@tempstore.shared'
- '@datetime.time' - '@datetime.time'
- '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface'
automatic_updates.cron_updater: automatic_updates.cron_updater:
class: Drupal\automatic_updates\CronUpdater class: Drupal\automatic_updates\CronUpdater
arguments: arguments:
...@@ -43,6 +44,7 @@ services: ...@@ -43,6 +44,7 @@ services:
- '@event_dispatcher' - '@event_dispatcher'
- '@tempstore.shared' - '@tempstore.shared'
- '@datetime.time' - '@datetime.time'
- '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface'
automatic_updates.staged_projects_validator: automatic_updates.staged_projects_validator:
class: Drupal\automatic_updates\Validator\StagedProjectsValidator class: Drupal\automatic_updates\Validator\StagedProjectsValidator
arguments: arguments:
......
...@@ -11,6 +11,7 @@ services: ...@@ -11,6 +11,7 @@ services:
- '@event_dispatcher' - '@event_dispatcher'
- '@tempstore.shared' - '@tempstore.shared'
- '@datetime.time' - '@datetime.time'
- '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface'
automatic_updates_extensions.validator.packages_installed_with_composer: automatic_updates_extensions.validator.packages_installed_with_composer:
class: Drupal\automatic_updates_extensions\Validator\PackagesInstalledWithComposerValidator class: Drupal\automatic_updates_extensions\Validator\PackagesInstalledWithComposerValidator
arguments: arguments:
......
...@@ -7,6 +7,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater; ...@@ -7,6 +7,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\package_manager\Exception\StageValidationException; use Drupal\package_manager\Exception\StageValidationException;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestPathFactory;
use Drupal\Tests\package_manager\Kernel\TestStageTrait; use Drupal\Tests\package_manager\Kernel\TestStageTrait;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\Handler\MockHandler;
...@@ -74,7 +75,8 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates ...@@ -74,7 +75,8 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates
$this->container->get('file_system'), $this->container->get('file_system'),
$this->container->get('event_dispatcher'), $this->container->get('event_dispatcher'),
$this->container->get('tempstore.shared'), $this->container->get('tempstore.shared'),
$this->container->get('datetime.time') $this->container->get('datetime.time'),
new TestPathFactory()
); );
} }
...@@ -163,7 +165,8 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates ...@@ -163,7 +165,8 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates
$this->container->get('file_system'), $this->container->get('file_system'),
$this->container->get('event_dispatcher'), $this->container->get('event_dispatcher'),
$this->container->get('tempstore.shared'), $this->container->get('tempstore.shared'),
$this->container->get('datetime.time') $this->container->get('datetime.time'),
new TestPathFactory()
); );
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Tests\automatic_updates_extensions\Kernel; namespace Drupal\Tests\automatic_updates_extensions\Kernel;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestPathFactory;
use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\Tests\user\Traits\UserCreationTrait;
/** /**
...@@ -49,14 +48,7 @@ class ExtensionUpdaterTest extends AutomaticUpdatesKernelTestBase { ...@@ -49,14 +48,7 @@ class ExtensionUpdaterTest extends AutomaticUpdatesKernelTestBase {
$this->createVirtualProject(__DIR__ . '/../../fixtures/fake-site'); $this->createVirtualProject(__DIR__ . '/../../fixtures/fake-site');
/** @var \Drupal\automatic_updates_extensions\ExtensionUpdater $updater */ $id = $this->container->get('automatic_updates_extensions.updater')->begin([
$updater = $this->container->get('automatic_updates_extensions.updater');
// @todo Remove this hack in https://www.drupal.org/i/3303174.
$property = new \ReflectionProperty($updater, 'pathFactory');
$property->setAccessible(TRUE);
$property->setValue($updater, new TestPathFactory());
$id = $updater->begin([
'my_module' => '9.8.1', 'my_module' => '9.8.1',
// Use a legacy version number to ensure they are converted to semantic // Use a legacy version number to ensure they are converted to semantic
// version numbers which will work with the drupal.org Composer facade. // version numbers which will work with the drupal.org Composer facade.
......
...@@ -28,6 +28,7 @@ use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface; ...@@ -28,6 +28,7 @@ use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface;
use PhpTuf\ComposerStager\Domain\Exception\InvalidArgumentException; use PhpTuf\ComposerStager\Domain\Exception\InvalidArgumentException;
use PhpTuf\ComposerStager\Domain\Exception\PreconditionException; use PhpTuf\ComposerStager\Domain\Exception\PreconditionException;
use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactory; use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactory;
use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface;
use PhpTuf\ComposerStager\Infrastructure\Value\PathList\PathList; use PhpTuf\ComposerStager\Infrastructure\Value\PathList\PathList;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
...@@ -190,8 +191,10 @@ class Stage { ...@@ -190,8 +191,10 @@ class Stage {
* The shared tempstore factory. * The shared tempstore factory.
* @param \Drupal\Component\Datetime\TimeInterface $time * @param \Drupal\Component\Datetime\TimeInterface $time
* The time service. * The time service.
* @param \PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface $path_factory
* (optional) The path factory service.
*/ */
public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $shared_tempstore, TimeInterface $time) { public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $shared_tempstore, TimeInterface $time, PathFactoryInterface $path_factory = NULL) {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->pathLocator = $path_locator; $this->pathLocator = $path_locator;
$this->beginner = $beginner; $this->beginner = $beginner;
...@@ -201,7 +204,7 @@ class Stage { ...@@ -201,7 +204,7 @@ class Stage {
$this->eventDispatcher = $event_dispatcher; $this->eventDispatcher = $event_dispatcher;
$this->time = $time; $this->time = $time;
$this->tempStore = $shared_tempstore->get('package_manager_stage'); $this->tempStore = $shared_tempstore->get('package_manager_stage');
$this->pathFactory = new PathFactory(); $this->pathFactory = $path_factory ?: new PathFactory();
} }
/** /**
......
...@@ -97,7 +97,8 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase { ...@@ -97,7 +97,8 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
$this->container->get('file_system'), $this->container->get('file_system'),
$this->container->get('event_dispatcher'), $this->container->get('event_dispatcher'),
$this->container->get('tempstore.shared'), $this->container->get('tempstore.shared'),
$this->container->get('datetime.time') $this->container->get('datetime.time'),
new TestPathFactory()
); );
} }
...@@ -234,14 +235,6 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase { ...@@ -234,14 +235,6 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
*/ */
trait TestStageTrait { trait TestStageTrait {
/**
* {@inheritdoc}
*/
public function __construct(...$arguments) {
parent::__construct(...$arguments);
$this->pathFactory = new TestPathFactory();
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
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