From 8cfd41460ffefa511ecf9a55057905df983a2c63 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Tue, 26 Sep 2017 13:36:53 +0200 Subject: [PATCH 1/5] Add dev:tests:run parameter to pass arguments to phpunit --- .../Console/Command/DevTestsRunCommand.php | 19 ++++++++++++++++++- .../Command/DevTestsRunCommandTest.php | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php b/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php index f26f0d5e79325..4f7b15c916da5 100644 --- a/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php +++ b/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** @@ -22,10 +23,16 @@ class DevTestsRunCommand extends Command */ const INPUT_ARG_TYPE = 'type'; + /** + * PHPUnit arguments parameter + */ + const INPUT_OPT_COMMAND_ARGUMENTS = 'arguments'; + const INPUT_OPT_COMMAND_ARGUMENTS_SHORT = 'c'; + /** * command name */ - const COMMAND_NAME = 'dev:tests:run'; + const COMMAND_NAME = 'dev:tests:run'; /** * Maps types (from user input) to phpunit test names @@ -56,6 +63,13 @@ protected function configure() 'Type of test to run. Available types: ' . implode(', ', array_keys($this->types)), 'default' ); + $this->addOption( + self::INPUT_OPT_COMMAND_ARGUMENTS, + self::INPUT_OPT_COMMAND_ARGUMENTS_SHORT, + InputOption::VALUE_REQUIRED, + 'Additional arguments for PHPUnit. Example: "-c\'--filter=MyTest\'" (no spaces)', + '' + ); parent::configure(); } @@ -87,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $dirName = realpath(BP . '/dev/tests/' . $dir); chdir($dirName); $command = PHP_BINARY . ' ' . BP . '/' . $vendorDir . '/phpunit/phpunit/phpunit ' . $options; + if ($commandArguments = $input->getOption(self::INPUT_OPT_COMMAND_ARGUMENTS)) { + $command .= ' ' . $commandArguments; + } $message = $dirName . '> ' . $command; $output->writeln(['', str_pad("---- {$message} ", 70, '-'), '']); passthru($command, $returnVal); diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php index 8ba3bd50ef301..862cdc336b803 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php @@ -34,4 +34,20 @@ public function testExecuteBadType() $commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']); $this->assertContains('Invalid type: "bad"', $commandTester->getDisplay()); } + + public function testPassArgumentsToPHPUnit() + { + $commandTester = new CommandTester($this->command); + $commandTester->execute( + [ + DevTestsRunCommand::INPUT_ARG_TYPE => 'unit', + '-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites', + ] + ); + $this->assertContains( + 'phpunit --list-suites', + $commandTester->getDisplay(), + 'Parameters should be passed to PHPUnit' + ); + } } From 2cccbe41cf3ec33d429218cde345fcff42d72344 Mon Sep 17 00:00:00 2001 From: Steven Vandeputte Date: Tue, 26 Sep 2017 14:25:39 +0200 Subject: [PATCH 2/5] Do not disable maintenance mode after running a backup. Keep the initial maintenance mode state before running the backup. Only disable maintenance mode if it was not setted before. Github issue: https://github.com/magento/magento2/issues/7951 --- .../Setup/Console/Command/BackupCommand.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/BackupCommand.php b/setup/src/Magento/Setup/Console/Command/BackupCommand.php index fafa47296d304..e38cf2e1eca69 100644 --- a/setup/src/Magento/Setup/Console/Command/BackupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/BackupCommand.php @@ -57,6 +57,12 @@ class BackupCommand extends AbstractSetupCommand */ private $deploymentConfig; + /** + * The initial maintenance mode state + * @var bool + */ + private $maintenanceModeInitialState; + /** * Constructor * @@ -73,6 +79,7 @@ public function __construct( $this->maintenanceMode = $maintenanceMode; $this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class); $this->deploymentConfig = $deploymentConfig; + $this->maintenanceModeInitialState = $this->maintenanceMode->isOn(); parent::__construct(); } @@ -147,8 +154,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('' . $e->getMessage() . ''); $returnValue = \Magento\Framework\Console\Cli::RETURN_FAILURE; } finally { - $output->writeln('Disabling maintenance mode'); - $this->maintenanceMode->set(false); + // Only disable maintenace mode if it wasn't turned on before + if (!$this->maintenanceModeInitialState) { + $output->writeln('Disabling maintenance mode'); + $this->maintenanceMode->set(false); + } } return $returnValue; } From d93173d42474bee2ecf20df1b23f5af82c30a48c Mon Sep 17 00:00:00 2001 From: Quinten Clause Date: Tue, 26 Sep 2017 14:45:16 +0200 Subject: [PATCH 3/5] Escape html before replace new line with break Fixes #10330 Multiline addresses are stored in the database with new lines The new lines were replaced and then escaped (in the wrong order) so the breaks were rendered as htmlentities
became <br /> --- .../Magento/Sales/Ui/Component/Listing/Column/Address.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php index 23a6e7a41a5b7..d900bb7ba670f 100644 --- a/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php @@ -49,9 +49,7 @@ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { - $item[$this->getData('name')] = $this->escaper->escapeHtml( - str_replace("\n", '
', $item[$this->getData('name')]) - ); + $item[$this->getData('name')] = nl2br($this->escaper->escapeHtml($item[$this->getData('name')])); } } From 5e8e8b4cce647f9786f25284b0dc8be07d8fa84e Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Wed, 27 Sep 2017 09:33:56 -0500 Subject: [PATCH 4/5] MAGETWO-80081: Merge magento/magento2#11058 commit 'refs/pull/11058/head' of https://github.com/magento/magento2 into MAGETWO-80081-PR-11058 - fixed unit tests --- .../Test/Unit/Ui/Component/Listing/Column/AddressTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php index 1a903ab68952c..c79b06da60c4e 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php @@ -47,7 +47,7 @@ public function testPrepareDataSource() { $itemName = 'itemName'; $oldItemValue = "itemValue\n"; - $newItemValue = 'itemValue
'; + $newItemValue = "itemValue
\n"; $dataSource = [ 'data' => [ 'items' => [ @@ -57,7 +57,7 @@ public function testPrepareDataSource() ]; $this->model->setData('name', $itemName); - $this->escaper->expects($this->once())->method('escapeHtml')->with($newItemValue)->willReturnArgument(0); + $this->escaper->expects($this->any())->method('escapeHtml')->with($oldItemValue)->willReturnArgument(0); $dataSource = $this->model->prepareDataSource($dataSource); $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); } From c460b3708620588bda8ce23cec85276653b04091 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Wed, 27 Sep 2017 11:23:39 -0500 Subject: [PATCH 5/5] MAGETWO-80115: Do not disable maintenance mode after running a backup. magento/magento2#11056 - suppressed static test --- setup/src/Magento/Setup/Console/Command/BackupCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/src/Magento/Setup/Console/Command/BackupCommand.php b/setup/src/Magento/Setup/Console/Command/BackupCommand.php index e38cf2e1eca69..a6ec091cc50b0 100644 --- a/setup/src/Magento/Setup/Console/Command/BackupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/BackupCommand.php @@ -116,6 +116,7 @@ protected function configure() /** * {@inheritdoc} + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function execute(InputInterface $input, OutputInterface $output) {