Skip to content

Commit 4d74562

Browse files
author
Elena Marchenko
committed
Merge branch 'develop' of https://github.com/magento/magento2ce into MAGETWO-54942
2 parents 8f009f4 + c0f4002 commit 4d74562

File tree

10 files changed

+234
-39
lines changed

10 files changed

+234
-39
lines changed

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,19 @@ public function testInitialize()
278278
->method('getOptionsReadOnly')
279279
->willReturn(false);
280280

281+
$firstExpectedCustomOption = clone $this->customOptionMock;
282+
$firstExpectedCustomOption->setData($optionsData['option2']);
283+
$secondExpectedCustomOption = clone $this->customOptionMock;
284+
$secondExpectedCustomOption->setData($optionsData['option3']);
281285
$this->customOptionFactoryMock->expects($this->any())
282286
->method('create')
283287
->willReturnMap([
284288
[
285289
['data' => $optionsData['option2']],
286-
(clone $this->customOptionMock)->setData($optionsData['option2'])
290+
$firstExpectedCustomOption
287291
], [
288292
['data' => $optionsData['option3']],
289-
(clone $this->customOptionMock)->setData($optionsData['option3'])
293+
$secondExpectedCustomOption
290294
]
291295
]);
292296

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Indexer\Setup;
8+
9+
use Magento\Framework\Setup\InstallDataInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Indexer\Model\IndexerFactory;
13+
use Magento\Framework\Indexer\ConfigInterface;
14+
15+
/**
16+
* Recurring data upgrade for indexer module
17+
*/
18+
class RecurringData implements InstallDataInterface
19+
{
20+
/**
21+
* @var IndexerFactory
22+
*/
23+
private $indexerFactory;
24+
25+
/**
26+
* @var ConfigInterface
27+
*/
28+
private $configInterface;
29+
30+
/**
31+
* RecurringData constructor.
32+
*
33+
* @param IndexerFactory $indexerFactory
34+
* @param ConfigInterface $configInterface
35+
*/
36+
public function __construct(
37+
IndexerFactory $indexerFactory,
38+
ConfigInterface $configInterface
39+
) {
40+
$this->indexerFactory = $indexerFactory;
41+
$this->configInterface = $configInterface;
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
48+
{
49+
foreach (array_keys($this->configInterface->getIndexers()) as $indexerId) {
50+
$indexer = $this->indexerFactory->create()->load($indexerId);
51+
if ($indexer->isScheduled()) {
52+
$indexer->getView()->unsubscribe()->subscribe();
53+
}
54+
}
55+
}
56+
}

app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ public function getBindArgumentValue()
602602
*/
603603
public function getMappedSqlField()
604604
{
605-
if (!$this->isAttributeSetOrCategory()) {
605+
if ($this->getAttribute() == 'sku') {
606+
$mappedSqlField = 'e.sku';
607+
} elseif (!$this->isAttributeSetOrCategory()) {
606608
$mappedSqlField = $this->getEavAttributeTableAlias() . '.value';
607609
} elseif ($this->getAttribute() == 'category_ids') {
608610
$mappedSqlField = 'e.entity_id';

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductPage" />
111111
</variation>
112112
<variation name="CreateConfigurableProductEntityTestVariation6" summary="Create Configurable Product with Creating New Category and New Attribute (Required Fields Only)" ticketId="MAGETWO-13361">
113-
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
113+
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
114114
<data name="product/data/configurable_attributes_data/dataset" xsi:type="string">two_searchable_options</data>
115115
<data name="product/data/name" xsi:type="string">Configurable Product %isolation%</data>
116116
<data name="product/data/sku" xsi:type="string">configurable_sku_%isolation%</data>

dev/tests/functional/tests/app/Magento/Setup/Test/TestCase/UpgradeSystemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function test(
7474
);
7575
$version = $upgrade['upgradeVersion'];
7676

77-
$suffix = "( (CE|EE))$";
77+
$suffix = "( (CE|EE|B2B))$";
7878
$normalVersion = '(0|[1-9]\d*)';
7979
$preReleaseVersion = "((0(?!\\d+(\\.|\\+|{$suffix}))|[1-9A-Za-z])[0-9A-Za-z-]*)";
8080
$buildVersion = '([0-9A-Za-z][0-9A-Za-z-]*)';

dev/tests/static/testsuite/Magento/Test/Legacy/ModuleDBChangeTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ class ModuleDBChangeTest extends \PHPUnit_Framework_TestCase
2222
*/
2323
protected static $changedFileList = '';
2424

25+
/**
26+
* @var string Path for Magento's composer.json
27+
*/
28+
protected static $composerFilePath = BP . '/composer.json';
29+
30+
/**
31+
* @var bool Is tests executes on develop branch
32+
*/
33+
protected static $isOnDevVersion = false;
34+
2535
/**
2636
* Set changed files paths and list for all projects
2737
*/
@@ -30,13 +40,23 @@ public static function setUpBeforeClass()
3040
foreach (glob(self::$changedFilesPattern) as $changedFile) {
3141
self::$changedFileList .= file_get_contents($changedFile) . PHP_EOL;
3242
}
43+
44+
if (file_exists(self::$composerFilePath)) {
45+
$jsonData = json_decode(file_get_contents(self::$composerFilePath));
46+
if (substr((string) $jsonData->version, -4) == '-dev') {
47+
self::$isOnDevVersion = true;
48+
}
49+
}
3350
}
3451

3552
/**
3653
* Test changes for module.xml files
3754
*/
3855
public function testModuleXmlFiles()
3956
{
57+
if (self::$isOnDevVersion) {
58+
$this->markTestSkipped('This test isn\'t applicable to the developer version of Magento');
59+
}
4060
preg_match_all('|etc/module\.xml$|mi', self::$changedFileList, $matches);
4161
$this->assertEmpty(
4262
reset($matches),
@@ -50,6 +70,9 @@ public function testModuleXmlFiles()
5070
*/
5171
public function testModuleSetupFiles()
5272
{
73+
if (self::$isOnDevVersion) {
74+
$this->markTestSkipped('This test isn\'t applicable to the developer version of Magento');
75+
}
5376
preg_match_all('|app/code/Magento/[^/]+/Setup/[^/]+$|mi', self::$changedFileList, $matches);
5477
$this->assertEmpty(
5578
reset($matches),

lib/internal/Magento/Framework/Data/Argument/Interpreter/ArrayType.php

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,70 @@ public function evaluate(array $data)
5454
*/
5555
private function sortItems($items)
5656
{
57-
uasort(
58-
$items,
59-
function ($firstItem, $secondItem) {
60-
$firstValue = 0;
61-
$secondValue = 0;
62-
if (isset($firstItem['sortOrder'])) {
63-
$firstValue = intval($firstItem['sortOrder']);
57+
$sortOrderDefined = $this->isSortOrderDefined($items);
58+
if ($sortOrderDefined) {
59+
$indexedItems = [];
60+
foreach ($items as $key => $item) {
61+
$indexedItems[] = ['key' => $key, 'item' => $item];
62+
}
63+
uksort(
64+
$indexedItems,
65+
function ($firstItemKey, $secondItemKey) use ($indexedItems) {
66+
return $this->compareItems($firstItemKey, $secondItemKey, $indexedItems);
6467
}
68+
);
69+
// Convert array of sorted items back to initial format
70+
$items = [];
71+
foreach ($indexedItems as $indexedItem) {
72+
$items[$indexedItem['key']] = $indexedItem['item'];
73+
}
74+
}
75+
return $items;
76+
}
6577

66-
if (isset($secondItem['sortOrder'])) {
67-
$secondValue = intval($secondItem['sortOrder']);
68-
}
78+
/**
79+
* Compare sortOrder of item
80+
*
81+
* @param mixed $firstItemKey
82+
* @param mixed $secondItemKey
83+
* @param array $indexedItems
84+
* @return int
85+
*/
86+
private function compareItems($firstItemKey, $secondItemKey, $indexedItems)
87+
{
88+
$firstItem = $indexedItems[$firstItemKey]['item'];
89+
$secondItem = $indexedItems[$secondItemKey]['item'];
90+
$firstValue = 0;
91+
$secondValue = 0;
92+
if (isset($firstItem['sortOrder'])) {
93+
$firstValue = intval($firstItem['sortOrder']);
94+
}
6995

70-
if ($firstValue == $secondValue) {
71-
return 0;
72-
}
73-
return $firstValue < $secondValue ? -1 : 1;
96+
if (isset($secondItem['sortOrder'])) {
97+
$secondValue = intval($secondItem['sortOrder']);
98+
}
99+
100+
if ($firstValue == $secondValue) {
101+
// These keys reflect initial relative position of items.
102+
// Allows stable sort for items with equal 'sortOrder'
103+
return $firstItemKey < $secondItemKey ? -1 : 1;
104+
}
105+
return $firstValue < $secondValue ? -1 : 1;
106+
}
107+
108+
/**
109+
* Determine if a sort order exists for any of the items.
110+
*
111+
* @param array $items
112+
* @return bool
113+
*/
114+
private function isSortOrderDefined($items)
115+
{
116+
foreach ($items as $itemData) {
117+
if (isset($itemData['sortOrder'])) {
118+
return true;
74119
}
75-
);
76-
return $items;
120+
}
121+
return false;
77122
}
78123
}

lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,40 @@ public function evaluateDataProvider()
103103
'key1' => '-value 1-',
104104
],
105105
],
106+
'pre-sorted array items' => [
107+
[
108+
'item' => [
109+
'key1' => ['value' => 'value 1'],
110+
'key4' => ['value' => 'value 4'],
111+
'key2' => ['value' => 'value 2', 'sortOrder' => 10],
112+
'key3' => ['value' => 'value 3'],
113+
],
114+
],
115+
[
116+
'key1' => '-value 1-',
117+
'key4' => '-value 4-',
118+
'key3' => '-value 3-',
119+
'key2' => '-value 2-',
120+
],
121+
],
122+
'sort order edge case values' => [
123+
[
124+
'item' => [
125+
'key1' => ['value' => 'value 1', 'sortOrder' => 101],
126+
'key4' => ['value' => 'value 4'],
127+
'key2' => ['value' => 'value 2', 'sortOrder' => -10],
128+
'key3' => ['value' => 'value 3'],
129+
'key5' => ['value' => 'value 5', 'sortOrder' => 20],
130+
],
131+
],
132+
[
133+
'key2' => '-value 2-',
134+
'key4' => '-value 4-',
135+
'key3' => '-value 3-',
136+
'key5' => '-value 5-',
137+
'key1' => '-value 1-',
138+
],
139+
],
106140
];
107141
}
108142
}

0 commit comments

Comments
 (0)