diff --git a/Classes/Console/Install/Upgrade/UpgradeWizardExecutor.php b/Classes/Console/Install/Upgrade/UpgradeWizardExecutor.php
index 501dad61..df791a1f 100644
--- a/Classes/Console/Install/Upgrade/UpgradeWizardExecutor.php
+++ b/Classes/Console/Install/Upgrade/UpgradeWizardExecutor.php
@@ -15,9 +15,11 @@
*/
use Helhum\Typo3Console\Tests\Unit\Install\Upgrade\Fixture\DummyUpgradeWizard;
+use Symfony\Component\Console\Output\BufferedOutput;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Updates\AbstractUpdate;
+use TYPO3\CMS\Install\Updates\ChattyInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
@@ -71,11 +73,17 @@ public function executeWizard(string $identifier, array $rawArguments = [], bool
'install'
);
+ $output = new BufferedOutput();
+ if ($upgradeWizard instanceof ChattyInterface) {
+ $upgradeWizard->setOutput($output);
+ }
+
$dbQueries = [];
$message = '';
if ($wizardImplementsInterface) {
$hasPerformed = $upgradeWizard->executeUpdate();
GeneralUtility::makeInstance(Registry::class)->set('installUpdate', $upgradeWizard->getIdentifier(), 1);
+ $message = trim($message . PHP_EOL . $output->fetch());
} else {
$hasPerformed = $upgradeWizard->performUpdate($dbQueries, $message);
}
diff --git a/Classes/Console/Install/Upgrade/UpgradeWizardResultRenderer.php b/Classes/Console/Install/Upgrade/UpgradeWizardResultRenderer.php
index 77decd29..f1f84749 100644
--- a/Classes/Console/Install/Upgrade/UpgradeWizardResultRenderer.php
+++ b/Classes/Console/Install/Upgrade/UpgradeWizardResultRenderer.php
@@ -38,19 +38,21 @@ public function render(array $upgradeWizardResults, ConsoleOutput $output)
$output->outputLine('Skipped upgrade wizard "%s" because it was not scheduled for execution or marked as done.', [$identifier]);
} else {
$output->outputLine('Successfully executed upgrade wizard "%s".', [$identifier]);
- if (!empty($messages = array_filter($result->getMessages()))) {
- $output->outputLine('Messages:');
- foreach ($messages as $message) {
- $output->outputLine(html_entity_decode(strip_tags($message)));
- }
- }
- if (!empty($queries = array_filter($result->getSqlQueries()))) {
- $output->outputLine('SQL Queries executed:');
- foreach ($queries as $query) {
- $output->outputLine(html_entity_decode(($query)));
- }
- }
}
+ if (!empty($messages = array_filter($result->getMessages()))) {
+ $this->printMessages($messages, 'Messages', $output);
+ }
+ if (!empty($queries = array_filter($result->getSqlQueries()))) {
+ $this->printMessages($queries, 'SQL Queries executed', $output);
+ }
+ }
+ }
+
+ private function printMessages(array $messages, string $title, ConsoleOutput $output)
+ {
+ $output->outputLine('%s:', [$title]);
+ foreach ($messages as $message) {
+ $output->outputLine(html_entity_decode(strip_tags($message)));
}
}
}
diff --git a/Tests/Console/Unit/Install/Upgrade/UpgradeWizardExecutorTest.php b/Tests/Console/Unit/Install/Upgrade/UpgradeWizardExecutorTest.php
index ddea0ae6..8492681e 100644
--- a/Tests/Console/Unit/Install/Upgrade/UpgradeWizardExecutorTest.php
+++ b/Tests/Console/Unit/Install/Upgrade/UpgradeWizardExecutorTest.php
@@ -18,6 +18,10 @@
use Helhum\Typo3Console\Install\Upgrade\UpgradeWizardFactory;
use Helhum\Typo3Console\Tests\Unit\Install\Upgrade\Fixture\DummyUpgradeWizard;
use Nimut\TestingFramework\TestCase\UnitTestCase;
+use Prophecy\Argument;
+use Prophecy\Prophecy\MethodProphecy;
+use Prophecy\Prophecy\ObjectProphecy;
+use Symfony\Component\Console\Output\OutputInterface;
class UpgradeWizardExecutorTest extends UnitTestCase
{
@@ -44,6 +48,7 @@ public function wizardIsCalledWhenNotDone()
{
$factoryProphecy = $this->prophesize(UpgradeWizardFactory::class);
$upgradeWizardProphecy = $this->prophesize(DummyUpgradeWizard::class);
+ $this->assertOutputInitForChattyWizard($upgradeWizardProphecy);
$upgradeWizardProphecy->shouldRenderWizard()->willReturn(true);
$upgradeWizardProphecy->performUpdate($queries = [], $message = '')->willReturn(true);
@@ -61,6 +66,7 @@ public function wizardIsCalledWhenNotDoneButCanStillNotPerform()
{
$factoryProphecy = $this->prophesize(UpgradeWizardFactory::class);
$upgradeWizardProphecy = $this->prophesize(DummyUpgradeWizard::class);
+ $this->assertOutputInitForChattyWizard($upgradeWizardProphecy);
$upgradeWizardProphecy->shouldRenderWizard()->willReturn(true);
$upgradeWizardProphecy->performUpdate($queries = [], $message = '')->willReturn(false);
@@ -88,4 +94,20 @@ public function wizardIsDoneButCalledWhenForced()
$result = $subject->executeWizard('Foo\\Test', [], true);
$this->assertFalse($result->hasPerformed());
}
+
+ /**
+ * @param DummyUpgradeWizard|ObjectProphecy $upgradeWizardProphecy
+ */
+ private function assertOutputInitForChattyWizard(ObjectProphecy $upgradeWizardProphecy)
+ {
+ if (!interface_exists('TYPO3\\CMS\\Install\\Updates\\ChattyInterface')) {
+ return;
+ }
+
+ /** @var OutputInterface $outputInterfaceArgument */
+ $outputInterfaceArgument = Argument::type(OutputInterface::class);
+ /** @var MethodProphecy $setOutputMethod */
+ $setOutputMethod = $upgradeWizardProphecy->setOutput($outputInterfaceArgument);
+ $setOutputMethod->shouldBeCalled();
+ }
}