From c884463174ab0c6105f97701b7edac5530d0ea48 Mon Sep 17 00:00:00 2001 From: Sebastian Schreiber Date: Fri, 10 Jan 2025 10:00:04 +0100 Subject: [PATCH] TASK: Use constructor injection for Container Resolves: #796 --- Resources/services.php | 2 +- composer.json | 2 +- src/Cli/Symfony/ConsoleKernel.php | 8 ------- src/Domain/Model/Deployment.php | 15 ++++-------- src/Domain/Model/FailedDeployment.php | 5 ++-- src/Domain/Service/TaskFactory.php | 16 +++++++------ src/Integration/Factory.php | 23 ++++++++++--------- tests/Unit/Command/DescribeCommandTest.php | 3 +-- tests/Unit/Domain/Model/DeploymentTest.php | 22 ++++++++---------- .../Domain/Model/RollbackWorkflowTest.php | 5 +++- .../Unit/Domain/Model/SimpleWorkflowTest.php | 5 +++- .../Service/ShellCommandServiceTest.php | 13 +++++++---- tests/Unit/Domain/Service/TaskFactoryTest.php | 4 +--- tests/Unit/Domain/Service/TaskManagerTest.php | 5 +++- tests/Unit/Integration/FactoryTest.php | 3 +-- tests/Unit/Task/BaseTaskTest.php | 3 +-- tests/Unit/Task/CleanupReleasesTaskTest.php | 3 +-- 17 files changed, 65 insertions(+), 72 deletions(-) diff --git a/Resources/services.php b/Resources/services.php index b091ca31..b6a1e67f 100644 --- a/Resources/services.php +++ b/Resources/services.php @@ -76,7 +76,7 @@ ->share(false); $services->set(Factory::class) - ->args([service(FilesystemInterface::class), service(LoggerInterface::class)]); + ->args([service('service_container'), service(FilesystemInterface::class), service(LoggerInterface::class)]); $services->alias(FactoryInterface::class, Factory::class); diff --git a/composer.json b/composer.json index 4c184afb..c6629bd9 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "neos/utility-files": "^7.3.10 || ^8.3.9", "symfony/config": "^5.0 || ^6.0 || ^7.0", "symfony/console": "^5.0 || ^6.0 || ^7.0", - "symfony/dependency-injection": "^5.0 || ^6.0", + "symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0", "symfony/finder": "^5.1 || ^6.0 || ^7.0", "symfony/options-resolver": "^5.0 || ^6.0 || ^7.0", "symfony/process": "^5.0 || ^6.0 || ^7.0", diff --git a/src/Cli/Symfony/ConsoleKernel.php b/src/Cli/Symfony/ConsoleKernel.php index 1b16f51b..109da52d 100644 --- a/src/Cli/Symfony/ConsoleKernel.php +++ b/src/Cli/Symfony/ConsoleKernel.php @@ -17,9 +17,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Reference; @@ -47,12 +45,6 @@ private function registerContainerConfiguration(LoaderInterface $loader): void private function build(ContainerBuilder $container): void { $container->addCompilerPass(new CommandsToApplicationCompilerPass()); - $container->registerForAutoconfiguration( - ContainerAwareInterface::class - )->addMethodCall( - 'setContainer', - [new Reference(ContainerInterface::class)] - ); $container->registerForAutoconfiguration( ShellCommandServiceAwareInterface::class )->addMethodCall( diff --git a/src/Domain/Model/Deployment.php b/src/Domain/Model/Deployment.php index e5094150..518e6d8d 100644 --- a/src/Domain/Model/Deployment.php +++ b/src/Domain/Model/Deployment.php @@ -12,24 +12,21 @@ namespace TYPO3\Surf\Domain\Model; use Neos\Utility\Files; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; use TYPO3\Surf\Domain\Enum\DeploymentStatus; use TYPO3\Surf\Exception as SurfException; use TYPO3\Surf\Integration\LoggerAwareTrait; use UnexpectedValueException; -use Webmozart\Assert\Assert; /** * This is the base object exposed to a deployment configuration script and serves as a configuration builder and * model for an actual deployment. */ -class Deployment implements LoggerAwareInterface, ContainerAwareInterface +class Deployment implements LoggerAwareInterface { use LoggerAwareTrait; - use ContainerAwareTrait; /** * The name of this deployment @@ -97,14 +94,16 @@ class Deployment implements LoggerAwareInterface, ContainerAwareInterface private bool $forceRun = false; private string $deploymentLockIdentifier; + private ContainerInterface $container; - public function __construct(string $name, string $deploymentLockIdentifier = null) + public function __construct(ContainerInterface $container, string $name, string $deploymentLockIdentifier = null) { $this->name = $name; $this->status = DeploymentStatus::UNKNOWN(); $this->releaseIdentifier = date('YmdHis'); $this->setDeploymentLockIdentifier($deploymentLockIdentifier); + $this->container = $container; } /** @@ -459,8 +458,6 @@ public function getTemporaryPath(): string public function rollback(bool $dryRun = false): void { - Assert::notNull($this->container); - $this->logger->notice('Rollback deployment ' . $this->name . ' (' . $this->releaseIdentifier . ')'); /** @var RollbackWorkflow $workflow */ @@ -500,8 +497,6 @@ private function setDeploymentLockIdentifier(?string $deploymentLockIdentifier = private function createSimpleWorkflow(): SimpleWorkflow { - Assert::notNull($this->container); - $workflow = $this->container->get(SimpleWorkflow::class); if (!$workflow instanceof SimpleWorkflow) { diff --git a/src/Domain/Model/FailedDeployment.php b/src/Domain/Model/FailedDeployment.php index 38f04eb8..009da6a8 100644 --- a/src/Domain/Model/FailedDeployment.php +++ b/src/Domain/Model/FailedDeployment.php @@ -11,6 +11,7 @@ namespace TYPO3\Surf\Domain\Model; +use Psr\Container\ContainerInterface; use TYPO3\Surf\Domain\Enum\DeploymentStatus; /** @@ -20,9 +21,9 @@ */ class FailedDeployment extends Deployment { - public function __construct(string $name) + public function __construct(ContainerInterface $container, string $name) { - parent::__construct($name); + parent::__construct($container, $name); $this->releaseIdentifier = null; } diff --git a/src/Domain/Service/TaskFactory.php b/src/Domain/Service/TaskFactory.php index 9bffd5c7..0082af09 100644 --- a/src/Domain/Service/TaskFactory.php +++ b/src/Domain/Service/TaskFactory.php @@ -11,20 +11,24 @@ namespace TYPO3\Surf\Domain\Service; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; use TYPO3\Surf\Domain\Model\Task; use UnexpectedValueException; -use Webmozart\Assert\Assert; /** * @final */ -class TaskFactory implements ContainerAwareInterface +class TaskFactory { - use ContainerAwareTrait; + + private ContainerInterface $container; + + public function __construct(ContainerInterface $container) + { + $this->container = $container; + } public function createTaskInstance(string $taskName): Task { @@ -33,8 +37,6 @@ public function createTaskInstance(string $taskName): Task private function createTask(string $taskName): Task { - Assert::notNull($this->container); - if (! $this->container->has($taskName)) { $task = new $taskName(); if ($task instanceof ShellCommandServiceAwareInterface) { diff --git a/src/Integration/Factory.php b/src/Integration/Factory.php index 83911ff8..5738a36f 100644 --- a/src/Integration/Factory.php +++ b/src/Integration/Factory.php @@ -14,29 +14,29 @@ use Monolog\Handler\StreamHandler; use Monolog\Logger; use Neos\Utility\Files; +use Psr\Container\ContainerInterface; +use Psr\Log\LoggerInterface; use RuntimeException; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; use TYPO3\Surf\Domain\Filesystem\FilesystemInterface; use TYPO3\Surf\Domain\Model\Deployment; use TYPO3\Surf\Domain\Model\FailedDeployment; use TYPO3\Surf\Exception\InvalidConfigurationException; -class Factory implements FactoryInterface, ContainerAwareInterface +class Factory implements FactoryInterface { - use ContainerAwareTrait; - protected OutputInterface $output; - protected Logger $logger; + protected LoggerInterface $logger; protected FilesystemInterface $filesystem; + private ContainerInterface $container; - public function __construct(FilesystemInterface $filesystem, Logger $logger) + public function __construct(ContainerInterface $container, FilesystemInterface $filesystem, LoggerInterface $logger) { $this->filesystem = $filesystem; $this->logger = $logger; + $this->container = $container; } public function getDeployment(string $deploymentName, string $configurationPath = null, bool $simulateDeployment = true, bool $initialize = true, bool $forceDeployment = false): Deployment @@ -45,7 +45,9 @@ public function getDeployment(string $deploymentName, string $configurationPath if (! $simulateDeployment) { $logFilePath = Files::concatenatePaths([$this->getWorkspacesBasePath($configurationPath), 'logs', $deployment->getName() . '.log']); - $this->logger->pushHandler(new StreamHandler($logFilePath)); + if($this->logger instanceof Logger){ + $this->logger->pushHandler(new StreamHandler($logFilePath)); + } } $deployment->setForceRun($forceDeployment); @@ -145,15 +147,14 @@ protected function createDeployment(string $deploymentName, string $path = null) if (! $this->filesystem->fileExists($deploymentPathAndFilename)) { $this->logger->error(sprintf("The deployment file %s does not exist.\n", $deploymentPathAndFilename)); - $deployment = new FailedDeployment($deploymentName); + $deployment = new FailedDeployment($this->container, $deploymentName); $deployment->setLogger($this->logger); return $deployment; } - $deployment = new Deployment($deploymentName); + $deployment = new Deployment($this->container, $deploymentName); $deployment->setLogger($this->logger); - $deployment->setContainer($this->container); $deployment->setDeploymentBasePath($deploymentConfigurationPath); $deployment->setWorkspacesBasePath($workspacesBasePath); diff --git a/tests/Unit/Command/DescribeCommandTest.php b/tests/Unit/Command/DescribeCommandTest.php index 589cd7ae..1d4db277 100644 --- a/tests/Unit/Command/DescribeCommandTest.php +++ b/tests/Unit/Command/DescribeCommandTest.php @@ -42,8 +42,7 @@ class DescribeCommandTest extends TestCase protected function setUp(): void { - $this->deployment = new Deployment('TestDeployment'); - $this->deployment->setContainer(static::getKernel()->getContainer()); + $this->deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); $this->node = new Node('TestNode'); $this->node->setHostname('hostname'); diff --git a/tests/Unit/Domain/Model/DeploymentTest.php b/tests/Unit/Domain/Model/DeploymentTest.php index 63fe35b3..22093c91 100644 --- a/tests/Unit/Domain/Model/DeploymentTest.php +++ b/tests/Unit/Domain/Model/DeploymentTest.php @@ -42,8 +42,7 @@ protected function tearDown(): void */ public function initializeUsesSimpleWorkflowAsDefault(): void { - $deployment = new Deployment('Test deployment'); - $deployment->setContainer(static::getKernel()->getContainer()); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Test deployment'); $deployment->initialize(); self::assertInstanceOf(SimpleWorkflow::class, $deployment->getWorkflow()); @@ -54,8 +53,7 @@ public function initializeUsesSimpleWorkflowAsDefault(): void */ public function getNodesReturnsNodesFromApplicationsAsSet(): void { - $deployment = new Deployment('Test deployment'); - $deployment->setContainer(static::getKernel()->getContainer()); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Test deployment'); $application1 = new Application('Test application 1'); $application2 = new Application('Test application 2'); @@ -81,8 +79,7 @@ public function getNodesReturnsNodesFromApplicationsAsSet(): void */ public function constructorCreatesReleaseIdentifier(): void { - $deployment = new Deployment('Test deployment'); - $deployment->setContainer(static::getKernel()->getContainer()); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Test deployment'); $releaseIdentifier = $deployment->getReleaseIdentifier(); @@ -98,7 +95,7 @@ public function initializeIsAllowedOnlyOnce(): void $workflow = new SimpleWorkflow($this->prophesize(TaskManager::class)->reveal()); - $deployment = new Deployment('Test deployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Test deployment'); $deployment->setWorkflow($workflow); $deployment->initialize(); @@ -113,8 +110,7 @@ public function initializeIsAllowedOnlyOnce(): void */ public function deploymentHasDefaultLockIdentifierIfNoIdentifierIsGiven($deploymentLockIdentifier): void { - $deployment = new Deployment('Some name', $deploymentLockIdentifier); - $deployment->setContainer(static::getKernel()->getContainer()); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Some name', $deploymentLockIdentifier); self::assertSame($deployment->getReleaseIdentifier(), $deployment->getDeploymentLockIdentifier()); } @@ -125,7 +121,7 @@ public function deploymentHasDefaultLockIdentifierIfNoIdentifierIsGiven($deploym public function deploymentHasDefinedLockIdentifier(): void { $deploymentLockIdentifier = 'Deployment lock identifier'; - $deployment = new Deployment('Some name', $deploymentLockIdentifier); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Some name', $deploymentLockIdentifier); self::assertSame($deploymentLockIdentifier, $deployment->getDeploymentLockIdentifier()); } @@ -138,7 +134,7 @@ public function deploymentHasLockIdentifierDefinedByEnvironmentVariable(): void $deploymentLockIdentifier = 'Deployment lock identifier'; putenv(sprintf('SURF_DEPLOYMENT_LOCK_IDENTIFIER=%s', $deploymentLockIdentifier)); - $deployment = new Deployment('Some name'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Some name'); self::assertSame($deploymentLockIdentifier, $deployment->getDeploymentLockIdentifier()); } @@ -148,7 +144,7 @@ public function deploymentHasLockIdentifierDefinedByEnvironmentVariable(): void */ public function deploymentContainsRelativeProjectRootPathForApplicationReleasePath(): void { - $deployment = new Deployment('Some name'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Some name'); $node = new Node('Node'); $node->setDeploymentPath('/deployment/path'); @@ -166,7 +162,7 @@ public function deploymentContainsRelativeProjectRootPathForApplicationReleasePa */ public function deploymentContainsChangedRelativeProjectRootPathForApplicationReleasePath(): void { - $deployment = new Deployment('Some name'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Some name'); $deployment->setRelativeProjectRootPath('htdocs'); $node = new Node('Node'); diff --git a/tests/Unit/Domain/Model/RollbackWorkflowTest.php b/tests/Unit/Domain/Model/RollbackWorkflowTest.php index 181217a7..d9969aae 100644 --- a/tests/Unit/Domain/Model/RollbackWorkflowTest.php +++ b/tests/Unit/Domain/Model/RollbackWorkflowTest.php @@ -21,9 +21,12 @@ use TYPO3\Surf\Domain\Service\TaskManager; use TYPO3\Surf\Exception as SurfException; use TYPO3\Surf\Task\Generic\RollbackTask; +use TYPO3\Surf\Tests\Unit\KernelAwareTrait; class RollbackWorkflowTest extends TestCase { + use KernelAwareTrait; + /** * @test */ @@ -367,7 +370,7 @@ public function tasksAreExecutedInTheRightOrder(): void */ protected function buildDeployment(array &$executedTasks = []): Deployment { - $deployment = new Deployment('Test rollback deployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Test rollback deployment'); $mockLogger = $this->createMock(LoggerInterface::class); // Enable log to console to debug tests // $mockLogger->expects(self::any())->method('log')->will($this->returnCallback(function($message) { diff --git a/tests/Unit/Domain/Model/SimpleWorkflowTest.php b/tests/Unit/Domain/Model/SimpleWorkflowTest.php index 5e983bc7..acea7c44 100644 --- a/tests/Unit/Domain/Model/SimpleWorkflowTest.php +++ b/tests/Unit/Domain/Model/SimpleWorkflowTest.php @@ -21,9 +21,12 @@ use TYPO3\Surf\Domain\Model\Workflow; use TYPO3\Surf\Domain\Service\TaskManager; use TYPO3\Surf\Exception as SurfException; +use TYPO3\Surf\Tests\Unit\KernelAwareTrait; class SimpleWorkflowTest extends TestCase { + use KernelAwareTrait; + /** * @test */ @@ -696,7 +699,7 @@ public function beforeAndAfterStageStepsAreIndependentOfApplications(callable $c */ protected function buildDeployment(array &$executedTasks = []): Deployment { - $deployment = new Deployment('Test deployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'Test deployment'); $mockLogger = $this->createMock(LoggerInterface::class); // Enable log to console to debug tests // $mockLogger->expects(self::any())->method('log')->will($this->returnCallback(function($message) { diff --git a/tests/Unit/Domain/Service/ShellCommandServiceTest.php b/tests/Unit/Domain/Service/ShellCommandServiceTest.php index 768b9f06..e8b065fb 100644 --- a/tests/Unit/Domain/Service/ShellCommandServiceTest.php +++ b/tests/Unit/Domain/Service/ShellCommandServiceTest.php @@ -17,12 +17,15 @@ use TYPO3\Surf\Domain\Model\Deployment; use TYPO3\Surf\Domain\Model\Node; use TYPO3\Surf\Domain\Service\ShellCommandService; +use TYPO3\Surf\Tests\Unit\KernelAwareTrait; /** * Unit test for the ShellCommandService */ class ShellCommandServiceTest extends TestCase { + use KernelAwareTrait; + /** * Test, if the given options are respected in executed SSH command * @@ -57,7 +60,7 @@ public function executeRemoteCommandRespectsOptionsInSshCommand( $node->setOption('privateKeyFile', $privateKey); } - $deployment = new Deployment('TestDeployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); /** @var LoggerInterface|MockObject $mockLogger */ $mockLogger = $this->createMock(LoggerInterface::class); @@ -131,7 +134,7 @@ public function executeRemoteCommandRespectsRemoteCommandExecutionHandler(): voi return [0, 'Hello World']; }); - $deployment = new Deployment('TestDeployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); /** @var LoggerInterface|MockObject $mockLogger */ $mockLogger = $this->createMock(LoggerInterface::class); @@ -161,7 +164,7 @@ public function executeOnRemoteNodeJoinsCommandsWithAndOperator(): void $node = new Node('TestNode'); $node->setHostname('asdf'); - $deployment = new Deployment('TestDeployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); /** @var LoggerInterface|MockObject $mockLogger */ $mockLogger = $this->createMock(LoggerInterface::class); @@ -192,7 +195,7 @@ public function executeOnLocalNodeJoinsCommandsWithAndOperator(): void $node = new Node('TestNode'); $node->onLocalhost(); - $deployment = new Deployment('TestDeployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); /** @var LoggerInterface|MockObject $mockLogger */ $mockLogger = $this->createMock(LoggerInterface::class); @@ -218,7 +221,7 @@ public function executeOnLocalNodeJoinsCommandsWithAndOperator(): void public function executeProcessProperlyLogsStandardAndErrorOutput(): void { $shellCommandService = new ShellCommandService(); - $deployment = new Deployment('TestDeployment'); + $deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); /** @var LoggerInterface|MockObject $mockLogger */ $mockLogger = $this->createMock(LoggerInterface::class); $deployment->setLogger($mockLogger); diff --git a/tests/Unit/Domain/Service/TaskFactoryTest.php b/tests/Unit/Domain/Service/TaskFactoryTest.php index bea87444..990d0741 100644 --- a/tests/Unit/Domain/Service/TaskFactoryTest.php +++ b/tests/Unit/Domain/Service/TaskFactoryTest.php @@ -30,9 +30,7 @@ class TaskFactoryTest extends TestCase protected function setUp(): void { - $container = self::getKernel()->getContainer(); - $this->subject = new TaskFactory(); - $this->subject->setContainer($container); + $this->subject = new TaskFactory(static::getKernel()->getContainer()); } /** diff --git a/tests/Unit/Domain/Service/TaskManagerTest.php b/tests/Unit/Domain/Service/TaskManagerTest.php index 3074d7a9..432cf941 100644 --- a/tests/Unit/Domain/Service/TaskManagerTest.php +++ b/tests/Unit/Domain/Service/TaskManagerTest.php @@ -22,10 +22,13 @@ use TYPO3\Surf\Domain\Model\Task; use TYPO3\Surf\Domain\Service\TaskFactory; use TYPO3\Surf\Domain\Service\TaskManager; +use TYPO3\Surf\Tests\Unit\KernelAwareTrait; class TaskManagerTest extends TestCase { use ProphecyTrait; + use KernelAwareTrait; + /** * @var ObjectProphecy|Task */ @@ -55,7 +58,7 @@ protected function setUp(): void { $this->node = new Node('Test node'); $this->application = new Application('Test application'); - $this->deployment = new Deployment('Test deployment'); + $this->deployment = new Deployment(static::getKernel()->getContainer(), 'Test deployment'); $logger = $this->prophesize(LoggerInterface::class); $this->deployment->setLogger($logger->reveal()); diff --git a/tests/Unit/Integration/FactoryTest.php b/tests/Unit/Integration/FactoryTest.php index 7df2771c..7a2366b0 100644 --- a/tests/Unit/Integration/FactoryTest.php +++ b/tests/Unit/Integration/FactoryTest.php @@ -60,8 +60,7 @@ protected function setUp(): void $this->logger = $this->prophesize(Logger::class); - $this->subject = new Factory($this->filesystem->reveal(), $this->logger->reveal()); - $this->subject->setContainer(static::getKernel()->getContainer()); + $this->subject = new Factory(static::getKernel()->getContainer(), $this->filesystem->reveal(), $this->logger->reveal()); } /** diff --git a/tests/Unit/Task/BaseTaskTest.php b/tests/Unit/Task/BaseTaskTest.php index 570e7dc6..5b8f2f2a 100644 --- a/tests/Unit/Task/BaseTaskTest.php +++ b/tests/Unit/Task/BaseTaskTest.php @@ -116,8 +116,7 @@ function ($command) use (&$commands, &$responses) { $this->node = new Node('TestNode'); $this->node->setHostname('hostname'); - $this->deployment = new Deployment('TestDeployment'); - $this->deployment->setContainer(static::getKernel()->getContainer()); + $this->deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); $this->mockLogger = $this->prophesize(LoggerInterface::class); $this->task->setLogger($this->mockLogger->reveal()); diff --git a/tests/Unit/Task/CleanupReleasesTaskTest.php b/tests/Unit/Task/CleanupReleasesTaskTest.php index 2602565e..5d222e97 100644 --- a/tests/Unit/Task/CleanupReleasesTaskTest.php +++ b/tests/Unit/Task/CleanupReleasesTaskTest.php @@ -54,8 +54,7 @@ protected function setUp(): void $this->node = new Node('TestNode'); $this->node->setHostname('hostname'); - $this->deployment = new Deployment('TestDeployment'); - $this->deployment->setContainer(static::getKernel()->getContainer()); + $this->deployment = new Deployment(static::getKernel()->getContainer(), 'TestDeployment'); $this->deployment->setLogger($this->mockLogger->reveal()); $this->deployment->setWorkspacesBasePath('./Data/Surf');