File tree Expand file tree Collapse file tree 5 files changed +25
-4
lines changed
tests/Unit/Domain/Service Expand file tree Collapse file tree 5 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 15
15
use Psr \Log \LoggerInterface ;
16
16
use Symfony \Component \Console \Application ;
17
17
use Symfony \Component \Console \Output \OutputInterface ;
18
- use Symfony \Component \DependencyInjection \Alias ;
19
- use Symfony \Component \DependencyInjection \Container ;
20
18
use Symfony \Component \DependencyInjection \ContainerInterface ;
21
19
use Symfony \Component \DependencyInjection \Loader \Configurator \ContainerConfigurator ;
22
20
use TYPO3 \Surf \Cli \Symfony \ConsoleApplication ;
Original file line number Diff line number Diff line change 20
20
use TYPO3 \Surf \Exception as SurfException ;
21
21
use TYPO3 \Surf \Integration \LoggerAwareTrait ;
22
22
use UnexpectedValueException ;
23
+ use Webmozart \Assert \Assert ;
23
24
24
25
/**
25
26
* This is the base object exposed to a deployment configuration script and serves as a configuration builder and
@@ -458,6 +459,8 @@ public function getTemporaryPath(): string
458
459
459
460
public function rollback (bool $ dryRun = false ): void
460
461
{
462
+ Assert::notNull ($ this ->container );
463
+
461
464
$ this ->logger ->notice ('Rollback deployment ' . $ this ->name . ' ( ' . $ this ->releaseIdentifier . ') ' );
462
465
463
466
/** @var RollbackWorkflow $workflow */
@@ -497,6 +500,8 @@ private function setDeploymentLockIdentifier(?string $deploymentLockIdentifier =
497
500
498
501
private function createSimpleWorkflow (): SimpleWorkflow
499
502
{
503
+ Assert::notNull ($ this ->container );
504
+
500
505
$ workflow = $ this ->container ->get (SimpleWorkflow::class);
501
506
502
507
if (!$ workflow instanceof SimpleWorkflow) {
Original file line number Diff line number Diff line change 11
11
12
12
namespace TYPO3 \Surf \Domain \Service ;
13
13
14
+ use Psr \Log \LoggerAwareInterface ;
15
+ use Psr \Log \LoggerInterface ;
14
16
use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
15
17
use Symfony \Component \DependencyInjection \ContainerAwareTrait ;
16
18
use TYPO3 \Surf \Domain \Model \Task ;
17
19
use UnexpectedValueException ;
20
+ use Webmozart \Assert \Assert ;
18
21
19
22
/**
20
23
* @final
@@ -30,11 +33,18 @@ public function createTaskInstance(string $taskName): Task
30
33
31
34
private function createTask (string $ taskName ): Task
32
35
{
36
+ Assert::notNull ($ this ->container );
37
+
33
38
if (! $ this ->container ->has ($ taskName )) {
34
39
$ task = new $ taskName ();
35
40
if ($ task instanceof ShellCommandServiceAwareInterface) {
36
41
$ task ->setShellCommandService (new ShellCommandService ());
37
42
}
43
+ if ($ task instanceof LoggerAwareInterface) {
44
+ /** @var LoggerInterface $logger */
45
+ $ logger = $ this ->container ->get (LoggerInterface::class);
46
+ $ task ->setLogger ($ logger );
47
+ }
38
48
} else {
39
49
$ task = $ this ->container ->get ($ taskName );
40
50
}
Original file line number Diff line number Diff line change 11
11
12
12
namespace TYPO3 \Surf \Tests \Unit \Domain \Service ;
13
13
14
+ use Psr \Log \LoggerInterface ;
14
15
use TYPO3 \Surf \Domain \Model \Application ;
15
16
use TYPO3 \Surf \Domain \Model \Deployment ;
16
17
use TYPO3 \Surf \Domain \Model \Node ;
@@ -31,4 +32,9 @@ public function getShell(): ShellCommandService
31
32
{
32
33
return $ this ->shell ;
33
34
}
35
+
36
+ public function getLogger (): LoggerInterface
37
+ {
38
+ return $ this ->logger ;
39
+ }
34
40
}
Original file line number Diff line number Diff line change 12
12
namespace TYPO3 \Surf \Tests \Unit \Domain \Service ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Psr \Log \LoggerInterface ;
16
+ use TYPO3 \Surf \Domain \Service \ShellCommandService ;
15
17
use TYPO3 \Surf \Domain \Service \TaskFactory ;
16
18
use TYPO3 \Surf \Task \CreateArchiveTask ;
17
19
use TYPO3 \Surf \Tests \Unit \KernelAwareTrait ;
@@ -49,11 +51,11 @@ public function createTaskInstance(): void
49
51
*/
50
52
public function createSyntheticServiceIfNotExists (): void
51
53
{
52
- /** @var CustomTask $customTask */
53
54
$ customTask = $ this ->subject ->createTaskInstance (CustomTask::class);
54
55
55
- self ::assertNotNull ($ customTask ->getShell ());
56
56
self ::assertInstanceOf (CustomTask::class, $ customTask );
57
+ self ::assertInstanceOf (LoggerInterface::class, $ customTask ->getLogger ());
58
+ self ::assertInstanceOf (ShellCommandService::class, $ customTask ->getShell ());
57
59
}
58
60
59
61
/**
You can’t perform that action at this time.
0 commit comments