Skip to content

Commit fa2439c

Browse files
authored
Merge pull request #1525 from magento-engcom/2.2-develop-prs
[EngCom] Public Pull Requests2.2
2 parents d5cf0c3 + c460b37 commit fa2439c

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Console\Command\Command;
99
use Symfony\Component\Console\Input\InputArgument;
1010
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213

1314
/**
@@ -22,10 +23,16 @@ class DevTestsRunCommand extends Command
2223
*/
2324
const INPUT_ARG_TYPE = 'type';
2425

26+
/**
27+
* PHPUnit arguments parameter
28+
*/
29+
const INPUT_OPT_COMMAND_ARGUMENTS = 'arguments';
30+
const INPUT_OPT_COMMAND_ARGUMENTS_SHORT = 'c';
31+
2532
/**
2633
* command name
2734
*/
28-
const COMMAND_NAME = 'dev:tests:run';
35+
const COMMAND_NAME = 'dev:tests:run';
2936

3037
/**
3138
* Maps types (from user input) to phpunit test names
@@ -56,6 +63,13 @@ protected function configure()
5663
'Type of test to run. Available types: ' . implode(', ', array_keys($this->types)),
5764
'default'
5865
);
66+
$this->addOption(
67+
self::INPUT_OPT_COMMAND_ARGUMENTS,
68+
self::INPUT_OPT_COMMAND_ARGUMENTS_SHORT,
69+
InputOption::VALUE_REQUIRED,
70+
'Additional arguments for PHPUnit. Example: "-c\'--filter=MyTest\'" (no spaces)',
71+
''
72+
);
5973

6074
parent::configure();
6175
}
@@ -87,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
87101
$dirName = realpath(BP . '/dev/tests/' . $dir);
88102
chdir($dirName);
89103
$command = PHP_BINARY . ' ' . BP . '/' . $vendorDir . '/phpunit/phpunit/phpunit ' . $options;
104+
if ($commandArguments = $input->getOption(self::INPUT_OPT_COMMAND_ARGUMENTS)) {
105+
$command .= ' ' . $commandArguments;
106+
}
90107
$message = $dirName . '> ' . $command;
91108
$output->writeln(['', str_pad("---- {$message} ", 70, '-'), '']);
92109
passthru($command, $returnVal);

app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,20 @@ public function testExecuteBadType()
3434
$commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']);
3535
$this->assertContains('Invalid type: "bad"', $commandTester->getDisplay());
3636
}
37+
38+
public function testPassArgumentsToPHPUnit()
39+
{
40+
$commandTester = new CommandTester($this->command);
41+
$commandTester->execute(
42+
[
43+
DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
44+
'-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
45+
]
46+
);
47+
$this->assertContains(
48+
'phpunit --list-suites',
49+
$commandTester->getDisplay(),
50+
'Parameters should be passed to PHPUnit'
51+
);
52+
}
3753
}

app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testPrepareDataSource()
4747
{
4848
$itemName = 'itemName';
4949
$oldItemValue = "itemValue\n";
50-
$newItemValue = 'itemValue<br/>';
50+
$newItemValue = "itemValue<br />\n";
5151
$dataSource = [
5252
'data' => [
5353
'items' => [
@@ -57,7 +57,7 @@ public function testPrepareDataSource()
5757
];
5858

5959
$this->model->setData('name', $itemName);
60-
$this->escaper->expects($this->once())->method('escapeHtml')->with($newItemValue)->willReturnArgument(0);
60+
$this->escaper->expects($this->any())->method('escapeHtml')->with($oldItemValue)->willReturnArgument(0);
6161
$dataSource = $this->model->prepareDataSource($dataSource);
6262
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
6363
}

app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ public function prepareDataSource(array $dataSource)
4949
{
5050
if (isset($dataSource['data']['items'])) {
5151
foreach ($dataSource['data']['items'] as & $item) {
52-
$item[$this->getData('name')] = $this->escaper->escapeHtml(
53-
str_replace("\n", '<br/>', $item[$this->getData('name')])
54-
);
52+
$item[$this->getData('name')] = nl2br($this->escaper->escapeHtml($item[$this->getData('name')]));
5553
}
5654
}
5755

setup/src/Magento/Setup/Console/Command/BackupCommand.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class BackupCommand extends AbstractSetupCommand
5757
*/
5858
private $deploymentConfig;
5959

60+
/**
61+
* The initial maintenance mode state
62+
* @var bool
63+
*/
64+
private $maintenanceModeInitialState;
65+
6066
/**
6167
* Constructor
6268
*
@@ -73,6 +79,7 @@ public function __construct(
7379
$this->maintenanceMode = $maintenanceMode;
7480
$this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class);
7581
$this->deploymentConfig = $deploymentConfig;
82+
$this->maintenanceModeInitialState = $this->maintenanceMode->isOn();
7683
parent::__construct();
7784
}
7885

@@ -109,6 +116,7 @@ protected function configure()
109116

110117
/**
111118
* {@inheritdoc}
119+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
112120
*/
113121
protected function execute(InputInterface $input, OutputInterface $output)
114122
{
@@ -147,8 +155,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
147155
$output->writeln('<error>' . $e->getMessage() . '</error>');
148156
$returnValue = \Magento\Framework\Console\Cli::RETURN_FAILURE;
149157
} finally {
150-
$output->writeln('<info>Disabling maintenance mode</info>');
151-
$this->maintenanceMode->set(false);
158+
// Only disable maintenace mode if it wasn't turned on before
159+
if (!$this->maintenanceModeInitialState) {
160+
$output->writeln('<info>Disabling maintenance mode</info>');
161+
$this->maintenanceMode->set(false);
162+
}
152163
}
153164
return $returnValue;
154165
}

0 commit comments

Comments
 (0)