diff --git a/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php b/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php index 68999b1372b6320cc4cd3931080235d562ddfc20..7a7df444bb6a1f88ec83718be29276d2e73872b5 100644 --- a/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php +++ b/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php @@ -19,7 +19,7 @@ class LogStatusCommandTest extends \PHPUnit_Framework_TestCase $resource = $this->getMock('Magento\Log\Model\Resource\Shell', [], [], '', false); $resourceFactory->expects($this->once())->method('create')->willReturn($resource); $resource->expects($this->once())->method('getTablesInfo')->willReturn( - [['name' => 'log_customer', 'rows' => '1', 'data_length' => '10', 'index_length' => '10']] + [['name' => 'log_customer', 'rows' => '1', 'data_length' => '16384', 'index_length' => '1024']] ); $objectManagerFactory->expects($this->once())->method('create')->willReturn($objectManager); $commandTester = new CommandTester(new LogStatusCommand($objectManagerFactory)); @@ -27,9 +27,9 @@ class LogStatusCommandTest extends \PHPUnit_Framework_TestCase $expectedMsg = '-----------------------------------+------------+------------+------------+' . PHP_EOL . 'Table Name | Rows | Data Size | Index Size |' . PHP_EOL . '-----------------------------------+------------+------------+------------+' . PHP_EOL - . 'log_customer | %s | %s | %s |' . PHP_EOL + . 'log_customer | 1 | 16.00Kb | 1.00Kb |' . PHP_EOL . '-----------------------------------+------------+------------+------------+' . PHP_EOL - . 'Total | %s | %s | %s |' . PHP_EOL + . 'Total | 1 | 16.00Kb | 1.00Kb |' . PHP_EOL . '-----------------------------------+------------+------------+------------+%w'; $this->assertStringMatchesFormat($expectedMsg, $commandTester->getDisplay()); } diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Log/Writer/Console.php b/setup/src/Magento/Setup/Module/Di/Compiler/Log/Writer/Console.php index 65c02f574d9f17805f1b37b14450041bf5567e9c..aa04630c150d4ccb8b63762d2470eaff5a77b8de 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/Log/Writer/Console.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/Log/Writer/Console.php @@ -42,7 +42,6 @@ class Console * * @param array $data * @return void - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function write(array $data) { @@ -51,22 +50,14 @@ class Console if (!count($classes)) { continue; } - if ($type === Log::GENERATION_SUCCESS) { - $startTag = '<info>'; - $endTag = '</info>'; - - } else { - $startTag = '<error>'; - $endTag = '</error>'; - } - - $this->console->writeln($startTag . $this->_messages[$type] . $endTag); + $this->console->writeln($this->getStartTag($type) . $this->_messages[$type] . $this->getEndTag($type)); foreach ($classes as $className => $messages) { if (count($messages)) { - $this->console->writeln($startTag . "\t" . $className . $endTag); + $this->console->writeln($this->getStartTag($type) . "\t" . $className . $this->getEndTag($type)); foreach ($messages as $message) { if ($message) { - $this->console->writeln($startTag . "\t\t" . $message . $endTag); + $this->console->writeln($this->getStartTag($type) . "\t\t" + . $message . $this->getEndTag($type)); if ($type != Log::GENERATION_SUCCESS) { $errorsCount++; } @@ -80,4 +71,34 @@ class Console $this->console->writeln('<error>' . 'Total Errors Count: ' . $errorsCount . '</error>'); } } + + /** + * Retrieve starting output tag + * + * @param string $type + * @return string + */ + private function getStartTag($type) + { + if ($type === Log::GENERATION_SUCCESS) { + return '<info>'; + } else { + return '<error>'; + } + } + + /** + * Retrieve ending output tag + * + * @param string $type + * @return string + */ + private function getEndTag($type) + { + if ($type === Log::GENERATION_SUCCESS) { + return '</info>'; + } else { + return '</error>'; + } + } }