Skip to content

Commit 3bbb6b3

Browse files
Merge branch '2.2-develop' of https://github.com/magento-performance/magento2ce into MAGETWO-75935
2 parents e0d572c + 9c14af7 commit 3bbb6b3

File tree

13 files changed

+213
-56
lines changed

13 files changed

+213
-56
lines changed

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

Lines changed: 18 additions & 1 deletion
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

Lines changed: 16 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 3 deletions
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

app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@
4141
<item name="total" xsi:type="string" translate="true">Row Total</item>
4242
</argument>
4343
</arguments>
44-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/view/items/renderer/default.phtml">
45-
<arguments>
46-
<argument name="columns" xsi:type="array">
47-
<item name="product" xsi:type="string" translate="false">col-product</item>
48-
<item name="status" xsi:type="string" translate="false">col-status</item>
49-
<item name="price-original" xsi:type="string" translate="false">col-price-original</item>
50-
<item name="price" xsi:type="string" translate="false">col-price</item>
51-
<item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
52-
<item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
53-
<item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item>
54-
<item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item>
55-
<item name="discont" xsi:type="string" translate="false">col-discont</item>
56-
<item name="total" xsi:type="string" translate="false">col-total</item>
57-
</argument>
58-
</arguments>
44+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" name="default_order_items_renderer" template="Magento_Sales::order/view/items/renderer/default.phtml">
45+
<arguments>
46+
<argument name="columns" xsi:type="array">
47+
<item name="product" xsi:type="string" translate="false">col-product</item>
48+
<item name="status" xsi:type="string" translate="false">col-status</item>
49+
<item name="price-original" xsi:type="string" translate="false">col-price-original</item>
50+
<item name="price" xsi:type="string" translate="false">col-price</item>
51+
<item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
52+
<item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
53+
<item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item>
54+
<item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item>
55+
<item name="discont" xsi:type="string" translate="false">col-discont</item>
56+
<item name="total" xsi:type="string" translate="false">col-total</item>
57+
</argument>
58+
</arguments>
5959
</block>
6060
<block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="Magento_Sales::items/column/qty.phtml" group="column"/>
6161
<block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="Magento_Sales::items/column/name.phtml" group="column"/>

app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
.widget.block {
334334
.lib-css(margin, @indent__base 0);
335335
}
336+
.links .widget.block { margin: 0; }
336337
}
337338

338339
.no-display:extend(.abs-no-display all) {

dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,10 @@ public function testStartActionCustomerToQuote()
141141
/**
142142
* Test return action with configurable product.
143143
*
144-
* #magentoDataFixture Magento/Paypal/_files/quote_express_configurable.php skipped due to MAGETWO-75517
144+
* @magentoDataFixture Magento/Paypal/_files/quote_express_configurable.php
145145
*/
146146
public function testReturnAction()
147147
{
148-
149-
$this->markTestSkipped('Test skipped due to MAGETWO-75517');
150148
$quote = $this->_objectManager->create(Quote::class);
151149
$quote->load('test_cart_with_configurable', 'reserved_order_id');
152150

dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express_configurable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
$requestInfo = new \Magento\Framework\DataObject(
2929
[
30-
'product' => 1,
31-
'selected_configurable_option' => 1,
32-
'qty' => 100,
30+
'product' => 2,
31+
'selected_configurable_option' => 2,
32+
'qty' => 1,
3333
'super_attribute' => [
3434
$attribute->getId() => $option->getId()
3535
]

dev/tests/unit/framework/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
error_reporting(E_ALL);
2121
ini_set('display_errors', 1);
2222

23+
/* For data consistency between displaying (printing) and serialization a float number */
24+
ini_set('precision', 14);
25+
ini_set('serialize_precision', 14);
26+
2327
/**
2428
* Set custom error handler
2529
*/

lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@ public function __construct(FrontendCacheInterface $cache, DbVersionInfo $dbVers
5050
public function beforeDispatch(FrontController $subject, RequestInterface $request)
5151
{
5252
if (!$this->cache->load('db_is_up_to_date')) {
53-
$errors = $this->dbVersionInfo->getDbVersionErrors();
54-
55-
if ($errors) {
53+
list($versionTooLowErrors, $versionTooHighErrors) = array_values($this->getGroupedDbVersionErrors());
54+
if ($versionTooHighErrors) {
55+
$message = 'Please update your modules: '
56+
. "Run \"composer install\" from the Magento root directory.\n"
57+
. "The following modules are outdated:\n%1";
58+
throw new LocalizedException(
59+
new Phrase($message, [implode("\n", $this->formatVersionTooHighErrors($versionTooHighErrors))])
60+
);
61+
} elseif ($versionTooLowErrors) {
5662
$message = 'Please upgrade your database: '
5763
. "Run \"bin/magento setup:upgrade\" from the Magento root directory.\n"
5864
. "The following modules are outdated:\n%1";
5965

60-
throw new LocalizedException(new Phrase($message, [implode("\n", $this->formatErrors($errors))]));
66+
throw new LocalizedException(
67+
new Phrase($message, [implode("\n", $this->formatVersionTooLowErrors($versionTooLowErrors))])
68+
);
6169
} else {
6270
$this->cache->save('true', 'db_is_up_to_date');
6371
}
@@ -70,7 +78,7 @@ public function beforeDispatch(FrontController $subject, RequestInterface $reque
7078
* @param array $errorsData array of error data from getOutOfDateDbErrors
7179
* @return array Messages that can be used to log the error
7280
*/
73-
private function formatErrors($errorsData)
81+
private function formatVersionTooLowErrors($errorsData)
7482
{
7583
$formattedErrors = [];
7684

@@ -82,4 +90,50 @@ private function formatErrors($errorsData)
8290

8391
return $formattedErrors;
8492
}
93+
94+
/**
95+
* Format each error in the error data from getOutOfDataDbErrors into a single message
96+
*
97+
* @param array $errorsData array of error data from getOutOfDateDbErrors
98+
* @return array Messages that can be used to log the error
99+
*/
100+
private function formatVersionTooHighErrors($errorsData)
101+
{
102+
$formattedErrors = [];
103+
104+
foreach ($errorsData as $error) {
105+
$formattedErrors[] = $error[DbVersionInfo::KEY_MODULE] . ' db ' . $error[DbVersionInfo::KEY_TYPE]
106+
. ' version: defined in codebase - ' . $error[DbVersionInfo::KEY_REQUIRED]
107+
. ', currently installed - ' . $error[DbVersionInfo::KEY_CURRENT];
108+
}
109+
110+
return $formattedErrors;
111+
}
112+
113+
/**
114+
* Return DB version errors grouped by 'version_too_low' and 'version_too_high'
115+
*
116+
* @return mixed
117+
*/
118+
private function getGroupedDbVersionErrors()
119+
{
120+
$allDbVersionErrors = $this->dbVersionInfo->getDbVersionErrors();
121+
return array_reduce(
122+
(array)$allDbVersionErrors,
123+
function ($carry, $item) {
124+
if ($item[DbVersionInfo::KEY_CURRENT] === 'none'
125+
|| $item[DbVersionInfo::KEY_CURRENT] < $item[DbVersionInfo::KEY_REQUIRED]
126+
) {
127+
$carry['version_too_low'][] = $item;
128+
} else {
129+
$carry['version_too_high'][] = $item;
130+
}
131+
return $carry;
132+
},
133+
[
134+
'version_too_low' => [],
135+
'version_too_high' => [],
136+
]
137+
);
138+
}
85139
}

lib/internal/Magento/Framework/Stdlib/DateTime.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public function isEmptyDate($date)
7979
* @param int $time
8080
* @return string The given time in given format
8181
*
82+
* @deprecated
83+
* @see Use Intl library for datetime handling: http://php.net/manual/en/book.intl.php
84+
*
8285
* @codeCoverageIgnore
8386
*/
8487
public function gmDate($format, $time)
@@ -92,6 +95,9 @@ public function gmDate($format, $time)
9295
* @param string $timeStr
9396
* @return int
9497
*
98+
* @deprecated
99+
* @see Use Intl library for datetime handling: http://php.net/manual/en/book.intl.php
100+
*
95101
* @codeCoverageIgnore
96102
*/
97103
public function strToTime($timeStr)

0 commit comments

Comments
 (0)