Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 0d3a6e6

Browse files
author
Eric Bohanon
committed
Merge remote-tracking branch 'remotes/origin/2.2-develop' into MAGETWO-72747-Rest-Shipment-Config
2 parents 0644f88 + 7ca7002 commit 0d3a6e6

File tree

18 files changed

+340
-63
lines changed

18 files changed

+340
-63
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
6161
/**
6262
* @var string|null
6363
*/
64-
private $order = null;
64+
private $relevanceOrderDirection = null;
6565

6666
/**
6767
* @var string
@@ -361,9 +361,19 @@ protected function _renderFiltersBefore()
361361
[]
362362
);
363363

364-
if ($this->order && 'relevance' === $this->order['field']) {
365-
$this->getSelect()->order('search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
364+
if ($this->relevanceOrderDirection) {
365+
$this->getSelect()->order(
366+
'search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->relevanceOrderDirection
367+
);
366368
}
369+
370+
/*
371+
* This order is required to force search results be the same
372+
* for the same requests and products with the same relevance
373+
* NOTE: this does not replace existing orders but ADDs one more
374+
*/
375+
$this->setOrder('entity_id');
376+
367377
return parent::_renderFiltersBefore();
368378
}
369379

@@ -385,10 +395,12 @@ protected function _renderFilters()
385395
*/
386396
public function setOrder($attribute, $dir = Select::SQL_DESC)
387397
{
388-
$this->order = ['field' => $attribute, 'dir' => $dir];
389-
if ($attribute !== 'relevance') {
398+
if ($attribute === 'relevance') {
399+
$this->relevanceOrderDirection = $dir;
400+
} else {
390401
parent::setOrder($attribute, $dir);
391402
}
403+
392404
return $this;
393405
}
394406

app/code/Magento/ConfigurableProduct/Model/Product/SaveHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ public function execute($entity, $arguments = [])
6666
$this->saveConfigurableProductAttributes($entity, $configurableOptions);
6767
}
6868

69-
$configurableLinks = (array) $extensionAttributes->getConfigurableProductLinks();
70-
$this->resourceModel->saveProducts($entity, $configurableLinks);
69+
$configurableLinks = $extensionAttributes->getConfigurableProductLinks();
70+
if ($configurableLinks !== null) {
71+
$configurableLinks = (array)$configurableLinks;
72+
$this->resourceModel->saveProducts($entity, $configurableLinks);
73+
}
7174

7275
return $entity;
7376
}

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/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,45 @@ public function testLoadWithFilterSearch($request, $filters, $expectedCount)
3131
$this->assertCount($expectedCount, $items);
3232
}
3333

34+
/**
35+
* @magentoDataFixture Magento/Framework/Search/_files/products_with_the_same_search_score.php
36+
*/
37+
public function testSearchResultsAreTheSameForSameRequests()
38+
{
39+
$howManySearchRequests = 3;
40+
$previousResult = null;
41+
42+
$objManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
43+
44+
foreach (range(1, $howManySearchRequests) as $i) {
45+
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $fulltextCollection */
46+
$fulltextCollection = $objManager->create(
47+
\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection::class,
48+
['searchRequestName' => 'quick_search_container']
49+
);
50+
51+
$fulltextCollection->addFieldToFilter('search_term', 'shorts');
52+
$fulltextCollection->setOrder('relevance');
53+
$fulltextCollection->load();
54+
$items = $fulltextCollection->getItems();
55+
$this->assertGreaterThan(
56+
0,
57+
count($items),
58+
sprintf("Search #%s result must not be empty", $i)
59+
);
60+
61+
if ($previousResult) {
62+
$this->assertEquals(
63+
$previousResult,
64+
array_keys($items),
65+
"Search result must be the same for the same requests"
66+
);
67+
}
68+
69+
$previousResult = array_keys($items);
70+
}
71+
}
72+
3473
public function filtersDataProviderSearch()
3574
{
3675
return [
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Catalog\Api\ProductRepositoryInterface;
8+
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Catalog\Model\Product\Visibility;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
Bootstrap::getInstance()->reinitialize();
15+
16+
/** @var ProductRepositoryInterface $productRepository */
17+
$productRepository = Bootstrap::getObjectManager()
18+
->create(ProductRepositoryInterface::class);
19+
20+
$howManyProducts = 5;
21+
22+
foreach (range(1, $howManyProducts) as $productId) {
23+
$product = Bootstrap::getObjectManager()->create(Product::class);
24+
$product->setTypeId(Type::TYPE_SIMPLE)
25+
->setAttributeSetId(4)
26+
->setWebsiteIds([1])
27+
->setName('Cool short' . $productId)
28+
->setSku('cool_shorts_' . $productId)
29+
->setPrice(42)
30+
->setShortDescription("Some description about shorts")
31+
->setTaxClassId(0)
32+
->setDescription('Some description about <b>shorts</b>')
33+
->setVisibility(Visibility::VISIBILITY_BOTH)
34+
->setStatus(Status::STATUS_ENABLED)
35+
->setStockData(
36+
[
37+
'use_config_manage_stock' => 1,
38+
'qty' => 100,
39+
'is_qty_decimal' => 0,
40+
'is_in_stock' => 1,
41+
]
42+
);
43+
44+
$productRepository->save($product);
45+
}

0 commit comments

Comments
 (0)