diff --git a/lib/internal/Magento/Framework/Setup/BackupRollback.php b/lib/internal/Magento/Framework/Setup/BackupRollback.php index 201220c71ffc1..cc55fc3e04747 100644 --- a/lib/internal/Magento/Framework/Setup/BackupRollback.php +++ b/lib/internal/Magento/Framework/Setup/BackupRollback.php @@ -22,9 +22,6 @@ */ class BackupRollback { - /** - * Default backup directory - */ public const DEFAULT_BACKUP_DIRECTORY = 'backups'; /** @@ -42,7 +39,7 @@ class BackupRollback /** * Logger * - * @var LoggerInterface + * @var ConsoleLoggerInterface */ private $log; @@ -69,14 +66,14 @@ class BackupRollback * Constructor * * @param ObjectManagerInterface $objectManager - * @param LoggerInterface $log + * @param ConsoleLoggerInterface $log * @param DirectoryList $directoryList * @param File $file * @param Helper $fsHelper */ public function __construct( ObjectManagerInterface $objectManager, - LoggerInterface $log, + ConsoleLoggerInterface $log, DirectoryList $directoryList, File $file, Helper $fsHelper diff --git a/lib/internal/Magento/Framework/Setup/ConsoleLogger.php b/lib/internal/Magento/Framework/Setup/ConsoleLogger.php index 01342ebb59b3a..47c8475c0f8d8 100644 --- a/lib/internal/Magento/Framework/Setup/ConsoleLogger.php +++ b/lib/internal/Magento/Framework/Setup/ConsoleLogger.php @@ -9,12 +9,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Formatter\OutputFormatterStyle; -/** - * Console Logger - * - * @package Magento\Setup\Model - */ -class ConsoleLogger implements LoggerInterface +class ConsoleLogger implements ConsoleLoggerInterface { /** * Indicator of whether inline output is started @@ -24,8 +19,6 @@ class ConsoleLogger implements LoggerInterface private $isInline = false; /** - * Console - * * @var OutputInterface */ protected $console; @@ -44,7 +37,7 @@ public function __construct(OutputInterface $output) } /** - * {@inheritdoc} + * @inheritdoc */ public function logSuccess($message) { @@ -53,7 +46,7 @@ public function logSuccess($message) } /** - * {@inheritdoc} + * @inheritdoc */ public function logError(\Exception $e) { @@ -62,7 +55,7 @@ public function logError(\Exception $e) } /** - * {@inheritdoc} + * @inheritdoc */ public function log($message) { @@ -71,7 +64,7 @@ public function log($message) } /** - * {@inheritdoc} + * @inheritdoc */ public function logInline($message) { @@ -80,7 +73,7 @@ public function logInline($message) } /** - * {@inheritdoc} + * @inheritdoc */ public function logMeta($message) { @@ -88,6 +81,15 @@ public function logMeta($message) $this->console->writeln('' . $message . ''); } + /** + * @inheritdoc + */ + public function logMetaInline($message) + { + $this->isInline = true; + $this->console->write('' . $message . ''); + } + /** * Terminates line if the inline logging is started * diff --git a/lib/internal/Magento/Framework/Setup/ConsoleLoggerInterface.php b/lib/internal/Magento/Framework/Setup/ConsoleLoggerInterface.php new file mode 100644 index 0000000000000..e727a1dedb3e7 --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/ConsoleLoggerInterface.php @@ -0,0 +1,64 @@ +objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class); - $this->log = $this->getMockForAbstractClass(LoggerInterface::class); + $this->log = $this->getMockForAbstractClass(ConsoleLoggerInterface::class); $this->directoryList = $this->createMock(DirectoryList::class); $this->path = realpath(__DIR__); $this->directoryList->expects($this->any()) diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 67bb890cce77e..ff2ed64cf2ab6 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -33,11 +33,11 @@ use Magento\Framework\Module\ModuleListInterface; use Magento\Framework\Module\ModuleResource; use Magento\Framework\Mview\TriggerCleaner; +use Magento\Framework\Setup\ConsoleLoggerInterface; use Magento\Framework\Setup\Declaration\Schema\DryRunLogger; use Magento\Framework\Setup\FilePermissions; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\InstallSchemaInterface; -use Magento\Framework\Setup\LoggerInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\PatchApplier; use Magento\Framework\Setup\Patch\PatchApplierFactory; @@ -136,7 +136,7 @@ class Installer /** * Logger * - * @var LoggerInterface + * @var ConsoleLoggerInterface */ private $log; @@ -269,7 +269,7 @@ class Installer * @param ModuleListInterface $moduleList * @param ModuleLoader $moduleLoader * @param AdminAccountFactory $adminAccountFactory - * @param LoggerInterface $log + * @param ConsoleLoggerInterface $log * @param ConnectionFactory $connectionFactory * @param MaintenanceMode $maintenanceMode * @param Filesystem $filesystem @@ -294,7 +294,7 @@ public function __construct( ModuleListInterface $moduleList, ModuleLoader $moduleLoader, AdminAccountFactory $adminAccountFactory, - LoggerInterface $log, + ConsoleLoggerInterface $log, ConnectionFactory $connectionFactory, MaintenanceMode $maintenanceMode, Filesystem $filesystem, @@ -394,7 +394,7 @@ public function install($request) $total = count($script) + 4 * count(array_filter($estimatedModules)); $this->progress = new Installer\Progress($total, 0); - $this->log->log('Starting Magento installation:'); + $this->log->logMeta('Starting Magento installation:'); foreach ($script as $item) { /* Note: Because the $this->DeploymentConfig gets written to, but plugins use $this->firstDeploymentConfig, @@ -912,7 +912,7 @@ public function installSchema(array $request) $this->setupModuleRegistry($setup); $this->setupCoreTables($setup); $this->cleanMemoryTables($setup); - $this->log->log('Schema creation/updates:'); + $this->log->logMeta('Schema creation/updates:'); $this->declarativeInstallSchema($request); $this->handleDBSchemaData($setup, 'schema', $request); /** @var Mysql $adapter */ @@ -960,7 +960,7 @@ public function installDataFixtures(array $request = []) $this->assertDbAccessible(); $setup = $this->dataSetupFactory->create(); $this->checkFilePermissionsForDbUpgrade(); - $this->log->log('Data install/update:'); + $this->log->logMeta('Data install/update:'); $this->handleDBSchemaData($setup, 'data', $request); @@ -1054,7 +1054,7 @@ private function handleDBSchemaData($setup, $type, array $request) if ($status == \Magento\Framework\Setup\ModuleDataSetupInterface::VERSION_COMPARE_GREATER) { $upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType); if ($upgrader) { - $this->log->logInline("Upgrading $type.. "); + $this->log->logMetaInline("Upgrading $type.. "); $upgrader->upgrade($setup, $moduleContextList[$moduleName]); if ($type === 'schema') { $resource->setDbVersion($moduleName, $configVer); @@ -1066,12 +1066,12 @@ private function handleDBSchemaData($setup, $type, array $request) } elseif ($configVer) { $installer = $this->getSchemaDataHandler($moduleName, $installType); if ($installer) { - $this->log->logInline("Installing $type... "); + $this->log->logMetaInline("Installing $type... "); $installer->install($setup, $moduleContextList[$moduleName]); } $upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType); if ($upgrader) { - $this->log->logInline("Upgrading $type... "); + $this->log->logMetaInline("Upgrading $type... "); $upgrader->upgrade($setup, $moduleContextList[$moduleName]); } } @@ -1097,9 +1097,9 @@ private function handleDBSchemaData($setup, $type, array $request) } if ($type === 'schema') { - $this->log->log('Schema post-updates:'); + $this->log->logMeta('Schema post-updates:'); } elseif ($type === 'data') { - $this->log->log('Data post-updates:'); + $this->log->logMeta('Data post-updates:'); } $handlerType = $type === 'schema' ? 'schema-recurring' : 'data-recurring'; @@ -1112,7 +1112,7 @@ private function handleDBSchemaData($setup, $type, array $request) $this->log->log("Module '{$moduleName}':"); $modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType); if ($modulePostUpdater) { - $this->log->logInline('Running ' . str_replace('-', ' ', $handlerType) . '...'); + $this->log->logMetaInline('Running ' . str_replace('-', ' ', $handlerType) . '...'); $modulePostUpdater->install($setup, $moduleContextList[$moduleName]); } $this->logProgress(); @@ -1367,7 +1367,7 @@ public function updateModulesSequence($keepGeneratedFiles = false) if (!$keepGeneratedFiles) { $this->cleanupGeneratedFiles(); } - $this->log->log('Updating modules:'); + $this->log->logMeta('Updating modules:'); $this->createModulesConfig([]); } @@ -1389,7 +1389,7 @@ public function getModulesConfig() */ public function uninstall() { - $this->log->log('Starting Magento uninstallation:'); + $this->log->logMeta('Starting Magento uninstallation:'); try { $this->cleanCaches(); @@ -1403,7 +1403,7 @@ public function uninstall() $this->cleanupDb(); - $this->log->log('File system cleanup:'); + $this->log->logMeta('File system cleanup:'); $messages = $this->cleanupFiles->clearAllFiles(); foreach ($messages as $message) { $this->log->log($message); @@ -1454,7 +1454,7 @@ private function cleanCaches() $cacheManager = $this->objectManagerProvider->get()->get(Manager::class); $types = $cacheManager->getAvailableTypes(); $cacheManager->clean($types); - $this->log->log('Cache cleared successfully'); + $this->log->logSuccess('Cache cleared successfully'); } /** @@ -1471,7 +1471,7 @@ private function flushCaches($types = []) $cacheManager = $this->objectManagerProvider->get()->get(Manager::class); $types = empty($types) ? $cacheManager->getAvailableTypes() : $types; $cacheManager->flush($types); - $this->log->log('Cache types ' . implode(',', $types) . ' flushed successfully'); + $this->log->logSuccess('Cache types ' . implode(',', $types) . ' flushed successfully'); } /** @@ -1703,7 +1703,7 @@ private function generateListOfModuleContext($resource, $type) */ private function cleanupGeneratedFiles() { - $this->log->log('File system cleanup:'); + $this->log->logMeta('File system cleanup:'); $messages = $this->cleanupFiles->clearCodeGeneratedFiles(); // unload Magento autoloader because it may be using compiled definition diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php index aeb5be93614fb..d65e15d1f87c6 100644 --- a/setup/src/Magento/Setup/Model/InstallerFactory.php +++ b/setup/src/Magento/Setup/Model/InstallerFactory.php @@ -8,7 +8,7 @@ use Laminas\ServiceManager\ServiceLocatorInterface; use Magento\Framework\App\ErrorHandler; -use Magento\Framework\Setup\LoggerInterface; +use Magento\Framework\Setup\ConsoleLoggerInterface; use Magento\Setup\Module\ResourceFactory; /** @@ -48,11 +48,11 @@ public function __construct( /** * Factory method for installer object * - * @param LoggerInterface $log + * @param ConsoleLoggerInterface $log * @return Installer * @throws \Magento\Setup\Exception */ - public function create(LoggerInterface $log) + public function create(ConsoleLoggerInterface $log) { return new Installer( $this->serviceLocator->get(\Magento\Framework\Setup\FilePermissions::class), diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php index adc451e6c473b..16b54411f00c1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php @@ -20,8 +20,8 @@ use Magento\Framework\Model\ResourceModel\Db\TransactionManager; use Magento\Framework\Module\ModuleList; use Magento\Framework\Module\ModuleList\Loader; +use Magento\Framework\Setup\ConsoleLoggerInterface; use Magento\Framework\Setup\FilePermissions; -use Magento\Framework\Setup\LoggerInterface; use Magento\Framework\Setup\SampleData\State; use Magento\Framework\Setup\SchemaPersistor; use Magento\Setup\Model\AdminAccountFactory; @@ -80,8 +80,8 @@ public function testCreate() $serviceLocatorMock->expects($this->any())->method('get') ->willReturnMap($this->getReturnValueMap()); - /** @var LoggerInterface|MockObject $log */ - $log = $this->getMockForAbstractClass(LoggerInterface::class); + /** @var ConsoleLoggerInterface|MockObject $log */ + $log = $this->getMockForAbstractClass(ConsoleLoggerInterface::class); /** @var ResourceFactory|MockObject $resourceFactoryMock */ $resourceFactoryMock = $this->createMock(ResourceFactory::class); $resourceFactoryMock diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index dbfa214301bf0..d9291fd706011 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -37,8 +37,8 @@ use Magento\Framework\Module\ModuleResource; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Registry; + use Magento\Framework\Setup\ConsoleLoggerInterface; use Magento\Framework\Setup\FilePermissions; - use Magento\Framework\Setup\LoggerInterface; use Magento\Framework\Setup\Patch\PatchApplier; use Magento\Framework\Setup\Patch\PatchApplierFactory; use Magento\Framework\Setup\SampleData\State; @@ -125,7 +125,7 @@ class InstallerTest extends TestCase private $adminFactory; /** - * @var LoggerInterface|MockObject + * @var ConsoleLoggerInterface|MockObject */ private $logger; @@ -256,7 +256,7 @@ protected function setUp(): void ); $this->moduleLoader = $this->createMock(Loader::class); $this->adminFactory = $this->createMock(AdminAccountFactory::class); - $this->logger = $this->getMockForAbstractClass(LoggerInterface::class); + $this->logger = $this->getMockForAbstractClass(ConsoleLoggerInterface::class); $this->connection = $this->getMockForAbstractClass(AdapterInterface::class); $this->maintenanceMode = $this->createMock(MaintenanceMode::class); $this->filesystem = $this->createMock(Filesystem::class); @@ -338,10 +338,11 @@ private function createObject($connectionFactory = false, $objectManagerProvider /** * @param array $request * @param array $logMessages + * @param array $logMetaMessages * @dataProvider installDataProvider * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testInstall(array $request, array $logMessages) + public function testInstall(array $request, array $logMessages, array $logMetaMessages) { $this->moduleList->method('getOne') ->willReturnMap( @@ -483,9 +484,17 @@ public function testInstall(array $request, array $logMessages) ], $logMessages ); - $this->logger->expects($this->exactly(2)) + call_user_func_array( + [ + $this->logger->expects($this->exactly(count($logMetaMessages)))->method('logMeta'), + 'withConsecutive' + ], + $logMetaMessages + ); + $this->logger->expects($this->exactly(3)) ->method('logSuccess') ->withConsecutive( + ['Cache cleared successfully'], ['Magento installation complete.'], ['Magento Admin URI: /'] ); @@ -503,16 +512,13 @@ public function installDataProvider() [ 'request' => $this->request, 'logMessages' => [ - ['Starting Magento installation:'], ['File permissions check...'], ['Required extensions check...'], ['Enabling Maintenance Mode...'], ['Installing deployment configuration...'], ['Installing database schema:'], - ['Schema creation/updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Schema post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Installing search configuration...'], @@ -523,14 +529,11 @@ public function installDataProvider() ['foo: 1'], ['bar: 1'], ['Installing data...'], - ['Data install/update:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Data post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Caches clearing:'], - ['Cache cleared successfully'], ['Disabling Maintenance Mode:'], ['Post installation file permissions check...'], ['Write installation date...'], @@ -538,6 +541,36 @@ public function installDataProvider() ['2 indexer(s) are in "Update by Schedule" mode.'], ['Sample Data is installed with errors. See log file for details'] ], + 'logMetaMessages' => [ + ['Starting Magento installation:'], + ['[Progress: 1 / 23]'], + ['[Progress: 2 / 23]'], + ['[Progress: 3 / 23]'], + ['[Progress: 4 / 23]'], + ['Schema creation/updates:'], + ['[Progress: 5 / 23]'], + ['[Progress: 6 / 23]'], + ['Schema post-updates:'], + ['[Progress: 7 / 23]'], + ['[Progress: 8 / 23]'], + ['[Progress: 9 / 23]'], + ['[Progress: 10 / 23]'], + ['[Progress: 11 / 23]'], + ['[Progress: 12 / 23]'], + ['[Progress: 13 / 23]'], + ['Data install/update:'], + ['[Progress: 14 / 23]'], + ['[Progress: 15 / 23]'], + ['Data post-updates:'], + ['[Progress: 16 / 23]'], + ['[Progress: 17 / 23]'], + ['[Progress: 18 / 23]'], + ['[Progress: 19 / 23]'], + ['[Progress: 20 / 23]'], + ['[Progress: 21 / 23]'], + ['[Progress: 22 / 23]'], + ['[Progress: 23 / 23]'], + ], ], [ 'request' => [ @@ -553,16 +586,13 @@ public function installDataProvider() AdminAccount::KEY_LAST_NAME => 'Doe' ], 'logMessages' => [ - ['Starting Magento installation:'], ['File permissions check...'], ['Required extensions check...'], ['Enabling Maintenance Mode...'], ['Installing deployment configuration...'], ['Installing database schema:'], - ['Schema creation/updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Schema post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Installing search configuration...'], @@ -573,15 +603,12 @@ public function installDataProvider() ['foo: 1'], ['bar: 1'], ['Installing data...'], - ['Data install/update:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Data post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Installing admin user...'], ['Caches clearing:'], - ['Cache cleared successfully'], ['Disabling Maintenance Mode:'], ['Post installation file permissions check...'], ['Write installation date...'], @@ -589,6 +616,37 @@ public function installDataProvider() ['2 indexer(s) are in "Update by Schedule" mode.'], ['Sample Data is installed with errors. See log file for details'] ], + 'logMetaMessages' => [ + ['Starting Magento installation:'], + ['[Progress: 1 / 24]'], + ['[Progress: 2 / 24]'], + ['[Progress: 3 / 24]'], + ['[Progress: 4 / 24]'], + ['Schema creation/updates:'], + ['[Progress: 5 / 24]'], + ['[Progress: 6 / 24]'], + ['Schema post-updates:'], + ['[Progress: 7 / 24]'], + ['[Progress: 8 / 24]'], + ['[Progress: 9 / 24]'], + ['[Progress: 10 / 24]'], + ['[Progress: 11 / 24]'], + ['[Progress: 12 / 24]'], + ['[Progress: 13 / 24]'], + ['Data install/update:'], + ['[Progress: 14 / 24]'], + ['[Progress: 15 / 24]'], + ['Data post-updates:'], + ['[Progress: 16 / 24]'], + ['[Progress: 17 / 24]'], + ['[Progress: 18 / 24]'], + ['[Progress: 19 / 24]'], + ['[Progress: 20 / 24]'], + ['[Progress: 21 / 24]'], + ['[Progress: 22 / 24]'], + ['[Progress: 23 / 24]'], + ['[Progress: 24 / 24]'], + ], ], ]; } @@ -598,13 +656,14 @@ public function installDataProvider() * * @param array $request * @param array $logMessages + * @param array $logMetaMessages * @throws RuntimeException * @throws FileSystemException * @throws LocalizedException * @dataProvider installWithOrderIncrementPrefixDataProvider * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testInstallWithOrderIncrementPrefix(array $request, array $logMessages) + public function testInstallWithOrderIncrementPrefix(array $request, array $logMessages, array $logMetaMessages) { $this->moduleList->method('getOne') ->willReturnMap( @@ -759,9 +818,17 @@ public function testInstallWithOrderIncrementPrefix(array $request, array $logMe ], $logMessages ); - $this->logger->expects($this->exactly(2)) + call_user_func_array( + [ + $this->logger->expects($this->exactly(count($logMetaMessages)))->method('logMeta'), + 'withConsecutive' + ], + $logMetaMessages + ); + $this->logger->expects($this->exactly(3)) ->method('logSuccess') ->withConsecutive( + ['Cache cleared successfully'], ['Magento installation complete.'], ['Magento Admin URI: /'] ); @@ -786,16 +853,13 @@ public function installWithOrderIncrementPrefixDataProvider(): array InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX => 'ORD' ], 'logMessages' => [ - ['Starting Magento installation:'], ['File permissions check...'], ['Required extensions check...'], ['Enabling Maintenance Mode...'], ['Installing deployment configuration...'], ['Installing database schema:'], - ['Schema creation/updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Schema post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Installing search configuration...'], @@ -806,15 +870,12 @@ public function installWithOrderIncrementPrefixDataProvider(): array ['foo: 1'], ['bar: 1'], ['Installing data...'], - ['Data install/update:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Data post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Creating sales order increment prefix...'], // << added ['Caches clearing:'], - ['Cache cleared successfully'], ['Disabling Maintenance Mode:'], ['Post installation file permissions check...'], ['Write installation date...'], @@ -822,6 +883,37 @@ public function installWithOrderIncrementPrefixDataProvider(): array ['2 indexer(s) are in "Update by Schedule" mode.'], ['Sample Data is installed with errors. See log file for details'] ], + 'logMetaMessages' => [ + ['Starting Magento installation:'], + ['[Progress: 1 / 24]'], + ['[Progress: 2 / 24]'], + ['[Progress: 3 / 24]'], + ['[Progress: 4 / 24]'], + ['Schema creation/updates:'], + ['[Progress: 5 / 24]'], + ['[Progress: 6 / 24]'], + ['Schema post-updates:'], + ['[Progress: 7 / 24]'], + ['[Progress: 8 / 24]'], + ['[Progress: 9 / 24]'], + ['[Progress: 10 / 24]'], + ['[Progress: 11 / 24]'], + ['[Progress: 12 / 24]'], + ['[Progress: 13 / 24]'], + ['Data install/update:'], + ['[Progress: 14 / 24]'], + ['[Progress: 15 / 24]'], + ['Data post-updates:'], + ['[Progress: 16 / 24]'], + ['[Progress: 17 / 24]'], + ['[Progress: 18 / 24]'], + ['[Progress: 19 / 24]'], + ['[Progress: 20 / 24]'], + ['[Progress: 21 / 24]'], + ['[Progress: 22 / 24]'], + ['[Progress: 23 / 24]'], + ['[Progress: 24 / 24]'], + ], ], ]; } @@ -842,22 +934,35 @@ public function testInstallWithInvalidRemoteStorageConfiguration(bool $isDeploym $request = $this->request; $logMessages = [ - ['Starting Magento installation:'], ['File permissions check...'], ['Required extensions check...'], ['Enabling Maintenance Mode...'], ['Installing deployment configuration...'], ['Installing database schema:'], - ['Schema creation/updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], - ['Schema post-updates:'], ['Module \'Foo_One\':'], ['Module \'Bar_Two\':'], ['Installing search configuration...'], ['Validating remote storage configuration...'], ]; + $logMetaMessages = [ + ['Starting Magento installation:'], + ['[Progress: 1 / 23]'], + ['[Progress: 2 / 23]'], + ['[Progress: 3 / 23]'], + ['[Progress: 4 / 23]'], + ['Schema creation/updates:'], + ['[Progress: 5 / 23]'], + ['[Progress: 6 / 23]'], + ['Schema post-updates:'], + ['[Progress: 7 / 23]'], + ['[Progress: 8 / 23]'], + ['[Progress: 9 / 23]'], + ['[Progress: 10 / 23]'], + ]; + $this->config->expects(static::atLeastOnce()) ->method('get') ->willReturnMap( @@ -997,6 +1102,13 @@ public function testInstallWithInvalidRemoteStorageConfiguration(bool $isDeploym ], $logMessages ); + call_user_func_array( + [ + $this->logger->expects(static::exactly(count($logMetaMessages)))->method('logMeta'), + 'withConsecutive' + ], + $logMetaMessages + ); $this->logger->expects(static::never())->method('logSuccess'); @@ -1029,6 +1141,7 @@ public function testInstallWithUnresolvableRemoteStorageValidator() // every log message call is expected $logMessages = $this->installDataProvider()[0]['logMessages']; + $logMetaMessages = $this->installDataProvider()[0]['logMetaMessages']; $this->config->expects(static::atLeastOnce()) ->method('get') @@ -1198,9 +1311,17 @@ public function testInstallWithUnresolvableRemoteStorageValidator() ], $logMessages ); - $this->logger->expects(static::exactly(2)) + call_user_func_array( + [ + $this->logger->expects(static::exactly(count($logMetaMessages)))->method('logMeta'), + 'withConsecutive' + ], + $logMetaMessages + ); + $this->logger->expects(static::exactly(3)) ->method('logSuccess') ->withConsecutive( + ['Cache cleared successfully'], ['Magento installation complete.'], ['Magento Admin URI: /'] ); @@ -1223,13 +1344,20 @@ public function testInstallWithInvalidRemoteStorageConfigurationWithEarlyExcepti $request = $this->request; $logMessages = [ - ['Starting Magento installation:'], ['File permissions check...'], ['Required extensions check...'], ['Enabling Maintenance Mode...'], ['Installing deployment configuration...'], ['Installing database schema:'], - ['Schema creation/updates:'] + ]; + + $logMetaMessages = [ + ['Starting Magento installation:'], + ['[Progress: 1 / 23]'], + ['[Progress: 2 / 23]'], + ['[Progress: 3 / 23]'], + ['[Progress: 4 / 23]'], + ['Schema creation/updates:'], ]; $this->config->expects(static::atLeastOnce()) @@ -1333,6 +1461,13 @@ public function testInstallWithInvalidRemoteStorageConfigurationWithEarlyExcepti ], $logMessages ); + call_user_func_array( + [ + $this->logger->expects(static::exactly(count($logMetaMessages)))->method('logMeta'), + 'withConsecutive' + ], + $logMetaMessages + ); $this->logger->expects(static::never())->method('logSuccess'); @@ -1478,12 +1613,20 @@ public function testUpdateModulesSequence() $this->logger ->method('log') ->withConsecutive( - ['Cache types config flushed successfully'], - ['Cache cleared successfully'], - ['File system cleanup:'], ['The directory \'/generation\' doesn\'t exist - skipping cleanup'], + ); + $this->logger + ->method('logMeta') + ->withConsecutive( + ['File system cleanup:'], ['Updating modules:'] ); + $this->logger + ->method('logSuccess') + ->withConsecutive( + ['Cache types config flushed successfully'], + ['Cache cleared successfully'], + ); $installer->updateModulesSequence(false); } @@ -1494,10 +1637,14 @@ public function testUpdateModulesSequenceKeepGenerated() $installer = $this->prepareForUpdateModulesTests(); $this->logger - ->method('log') + ->method('logSuccess') ->withConsecutive( ['Cache types config flushed successfully'], ['Cache cleared successfully'], + ); + $this->logger + ->method('logMeta') + ->withConsecutive( ['Updating modules:'] ); @@ -1546,7 +1693,6 @@ public function testUninstall(): void ->method('get') ->with(Manager::class) ->willReturn($cacheManager); - $this->logger->expects($this->once())->method('logSuccess')->with('Magento uninstallation complete.'); $this->cleanupFiles->expects($this->once())->method('clearAllFiles')->willReturn( [ "The directory '/var' doesn't exist - skipping cleanup", @@ -1557,15 +1703,24 @@ public function testUninstall(): void $this->logger ->method('log') ->withConsecutive( - ['Starting Magento uninstallation:'], - ['Cache cleared successfully'], ['No database connection defined - skipping database cleanup'], - ['File system cleanup:'], ["The directory '/var' doesn't exist - skipping cleanup"], ["The directory '/static' doesn't exist - skipping cleanup"], ["The file '/config/ConfigOne.php' doesn't exist - skipping cleanup"], ["The file '/config/ConfigTwo.php' doesn't exist - skipping cleanup"] ); + $this->logger + ->method('logMeta') + ->withConsecutive( + ['Starting Magento uninstallation:'], + ['File system cleanup:'], + ); + $this->logger + ->method('logSuccess') + ->withConsecutive( + ['Cache cleared successfully'], + ['Magento uninstallation complete.'], + ); $this->object->uninstall(); }