Skip to content

Commit 9f2d501

Browse files
author
Dmytro Voskoboinikov
committed
Merge commit 'refs/pull/1570/head' of https://github.com/magento/magento2ce into Qwerty-PR20171006
2 parents a4991db + 7365554 commit 9f2d501

File tree

15 files changed

+302
-38
lines changed

15 files changed

+302
-38
lines changed

app/code/Magento/CatalogImportExport/Model/Indexer/Product/Flat/Plugin/Import.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin;
77

8+
use Magento\Catalog\Model\Indexer\Product\Flat\State as FlatState;
9+
810
class Import
911
{
12+
/**
13+
* @var \Magento\Catalog\Model\Indexer\Product\Flat\State
14+
*/
15+
private $flatState;
16+
1017
/**
1118
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor
1219
*/
1320
protected $_productFlatIndexerProcessor;
1421

1522
/**
1623
* @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor
24+
* @param \Magento\Catalog\Model\Indexer\Product\Flat\State $flatState
1725
*/
18-
public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor)
19-
{
26+
public function __construct(
27+
\Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor,
28+
FlatState $flatState
29+
) {
2030
$this->_productFlatIndexerProcessor = $productFlatIndexerProcessor;
31+
$this->flatState = $flatState;
2132
}
2233

2334
/**
@@ -31,7 +42,10 @@ public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processo
3142
*/
3243
public function afterImportSource(\Magento\ImportExport\Model\Import $subject, $import)
3344
{
34-
$this->_productFlatIndexerProcessor->markIndexerAsInvalid();
45+
if ($this->flatState->isFlatEnabled() && !$this->_productFlatIndexerProcessor->isIndexerScheduled()) {
46+
$this->_productFlatIndexerProcessor->markIndexerAsInvalid();
47+
}
48+
3549
return $import;
3650
}
3751
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,79 @@
55
*/
66
namespace Magento\CatalogImportExport\Test\Unit\Model\Indexer\Product\Flat\Plugin;
77

8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
810
class ImportTest extends \PHPUnit\Framework\TestCase
911
{
10-
public function testAfterImportSource()
12+
/**
13+
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject
14+
*/
15+
private $processorMock;
16+
17+
/**
18+
* @var \Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import
19+
*/
20+
private $model;
21+
22+
/**
23+
* @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $flatStateMock;
26+
27+
/**
28+
* @var \Magento\ImportExport\Model\Import|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $subjectMock;
31+
32+
protected function setUp()
1133
{
12-
/**
13-
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|
14-
* \PHPUnit_Framework_MockObject_MockObject $processorMock
15-
*/
16-
$processorMock = $this->createPartialMock(
17-
\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class,
18-
['markIndexerAsInvalid']
34+
$this->processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class)
35+
->disableOriginalConstructor()
36+
->setMethods(['markIndexerAsInvalid', 'isIndexerScheduled'])
37+
->getMock();
38+
39+
$this->flatStateMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\State::class)
40+
->disableOriginalConstructor()
41+
->setMethods(['isFlatEnabled'])
42+
->getMock();
43+
44+
$this->subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class)
45+
->disableOriginalConstructor()
46+
->getMock();
47+
48+
$this->model = (new ObjectManager($this))->getObject(
49+
\Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import::class,
50+
[
51+
'productFlatIndexerProcessor' => $this->processorMock,
52+
'flatState' => $this->flatStateMock
53+
]
1954
);
55+
}
2056

21-
$subjectMock = $this->createMock(\Magento\ImportExport\Model\Import::class);
22-
$processorMock->expects($this->once())->method('markIndexerAsInvalid');
57+
public function testAfterImportSourceWithFlatEnabledAndIndexerScheduledDisabled()
58+
{
59+
$this->flatStateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true);
60+
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(false);
61+
$this->processorMock->expects($this->once())->method('markIndexerAsInvalid');
62+
$someData = [1, 2, 3];
63+
$this->assertEquals($someData, $this->model->afterImportSource($this->subjectMock, $someData));
64+
}
2365

66+
public function testAfterImportSourceWithFlatDisabledAndIndexerScheduledDisabled()
67+
{
68+
$this->flatStateMock->expects($this->once())->method('isFlatEnabled')->willReturn(false);
69+
$this->processorMock->expects($this->never())->method('isIndexerScheduled')->willReturn(false);
70+
$this->processorMock->expects($this->never())->method('markIndexerAsInvalid');
2471
$someData = [1, 2, 3];
72+
$this->assertEquals($someData, $this->model->afterImportSource($this->subjectMock, $someData));
73+
}
2574

26-
$model = new \Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import($processorMock);
27-
$this->assertEquals($someData, $model->afterImportSource($subjectMock, $someData));
75+
public function testAfterImportSourceWithFlatEnabledAndIndexerScheduledEnabled()
76+
{
77+
$this->flatStateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true);
78+
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(true);
79+
$this->processorMock->expects($this->never())->method('markIndexerAsInvalid');
80+
$someData = [1, 2, 3];
81+
$this->assertEquals($someData, $this->model->afterImportSource($this->subjectMock, $someData));
2882
}
2983
}

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,28 +301,40 @@ public function getProductAttributes($storeId, array $productIds, array $attribu
301301
foreach ($attributeTypes as $backendType => $attributeIds) {
302302
if ($attributeIds) {
303303
$tableName = $this->getTable('catalog_product_entity_' . $backendType);
304-
$selects[] = $this->connection->select()->from(
305-
['t_default' => $tableName],
306-
[$linkField, 'attribute_id']
304+
305+
$select = $this->connection->select()->from(
306+
['t' => $tableName],
307+
[
308+
$linkField => 't.' . $linkField,
309+
'attribute_id' => 't.attribute_id',
310+
'value' => $this->unifyField($ifStoreValue, $backendType),
311+
]
307312
)->joinLeft(
308313
['t_store' => $tableName],
309314
$this->connection->quoteInto(
310-
't_default.' . $linkField . '=t_store.' . $linkField .
311-
' AND t_default.attribute_id=t_store.attribute_id' .
315+
't.' . $linkField . '=t_store.' . $linkField .
316+
' AND t.attribute_id=t_store.attribute_id' .
312317
' AND t_store.store_id = ?',
313318
$storeId
314319
),
315-
['value' => $this->unifyField($ifStoreValue, $backendType)]
316-
)->where(
317-
't_default.store_id = ?',
318-
0
320+
[]
321+
)->joinLeft(
322+
['t_default' => $tableName],
323+
$this->connection->quoteInto(
324+
't.' . $linkField . '=t_default.' . $linkField .
325+
' AND t.attribute_id=t_default.attribute_id' .
326+
' AND t_default.store_id = ?',
327+
0
328+
),
329+
[]
319330
)->where(
320-
't_default.attribute_id IN (?)',
331+
't.attribute_id IN (?)',
321332
$attributeIds
322333
)->where(
323-
't_default.' . $linkField . ' IN (?)',
334+
't.' . $linkField . ' IN (?)',
324335
array_keys($productLinkFieldsToEntityIdMap)
325-
);
336+
)->distinct();
337+
$selects[] = $select;
326338
}
327339
}
328340

app/code/Magento/Config/Model/Config/Backend/File.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public function beforeSave()
111111
} else {
112112
if (is_array($value) && !empty($value['delete'])) {
113113
$this->setValue('');
114+
} elseif (is_array($value) && !empty($value['value'])) {
115+
$this->setValue($value['value']);
114116
} else {
115117
$this->unsValue();
116118
}

app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public function getProducts(ProductInterface $product)
6363
);
6464

6565
$this->linkedProductMap[$product->getId()] = $this->collectionFactory->create()
66-
->addAttributeToSelect(['price', 'special_price', 'special_from_date', 'special_to_date'])
66+
->addAttributeToSelect(
67+
['price', 'special_price', 'special_from_date', 'special_to_date', 'tax_class_id']
68+
)
6769
->addIdFilter($productIds)
6870
->getItems();
6971
}

app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/LowestPriceOptionsProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testGetProducts()
9090
$this->productCollection
9191
->expects($this->once())
9292
->method('addAttributeToSelect')
93-
->with(['price', 'special_price', 'special_from_date', 'special_to_date'])
93+
->with(['price', 'special_price', 'special_from_date', 'special_to_date', 'tax_class_id'])
9494
->willReturnSelf();
9595
$this->productCollection->expects($this->once())->method('addIdFilter')->willReturnSelf();
9696
$this->productCollection->expects($this->once())->method('getItems')->willReturn($linkedProducts);

app/code/Magento/Customer/Model/Customer/Source/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function toOptionArray()
5656
$customerGroups = [];
5757
$customerGroups[] = [
5858
'label' => __('ALL GROUPS'),
59-
'value' => GroupInterface::CUST_GROUP_ALL,
59+
'value' => (string)GroupInterface::CUST_GROUP_ALL,
6060
];
6161

6262
/** @var GroupSearchResultsInterface $groups */

app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ protected function setUp()
7171
public function testToOptionArray()
7272
{
7373
$customerGroups = [
74-
['label' => __('ALL GROUPS'), 'value' => 32000],
75-
['label' => __('NOT LOGGED IN'), 'value' => 0]
74+
['label' => __('ALL GROUPS'), 'value' => '32000'],
75+
['label' => __('NOT LOGGED IN'), 'value' => '0'],
7676
];
7777

7878
$this->moduleManagerMock->expects($this->any())
@@ -95,11 +95,17 @@ public function testToOptionArray()
9595
->setMethods(['getCode', 'getId'])
9696
->getMockForAbstractClass();
9797
$groupTest->expects($this->any())->method('getCode')->willReturn(__('NOT LOGGED IN'));
98-
$groupTest->expects($this->any())->method('getId')->willReturn(0);
98+
$groupTest->expects($this->any())->method('getId')->willReturn('0');
9999
$groups = [$groupTest];
100100

101101
$this->searchResultMock->expects($this->any())->method('getItems')->willReturn($groups);
102102

103-
$this->assertEquals($customerGroups, $this->model->toOptionArray());
103+
$actualCustomerGroups = $this->model->toOptionArray();
104+
105+
$this->assertEquals($customerGroups, $actualCustomerGroups);
106+
107+
foreach ($actualCustomerGroups as $actualCustomerGroup) {
108+
$this->assertInternalType('string', $actualCustomerGroup['value']);
109+
}
104110
}
105111
}

app/code/Magento/Translation/Model/Js/DataProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ protected function getPhrases($content)
134134
{
135135
$phrases = [];
136136
foreach ($this->config->getPatterns() as $pattern) {
137-
$result = preg_match_all($pattern, $content, $matches);
137+
$concatenatedContent = preg_replace('~(["\'])\s*?\+\s*?\1~', '', $content);
138+
$result = preg_match_all($pattern, $concatenatedContent, $matches);
138139

139140
if ($result) {
140141
if (isset($matches[2])) {
141142
foreach ($matches[2] as $match) {
142-
$phrases[] = str_replace('\\\'', '\'', $match);
143+
$phrases[] = str_replace(["\'", '\"'], ["'", '"'], $match);
143144
}
144145
}
145146
}

app/code/Magento/Translation/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
<argument name="patterns" xsi:type="array">
6666
<item name="i18n_translation" xsi:type="string"><![CDATA[~i18n\:\s*(["'])(.*?)(?<!\\)\1~]]></item>
6767
<item name="translate_wrapping" xsi:type="string"><![CDATA[~translate\=("')([^\'].*?)\'\"~]]></item>
68-
<item name="mage_translation_widget" xsi:type="string">~\$\.mage\.__\((?s)[^'"]*?(['"])(.+?)\1(?s).*?\)~</item>
69-
<item name="mage_translation_static" xsi:type="string">~\$t\((?s)[^'"]*?(["'])(.+?)\1(?s).*?\)~</item>
68+
<item name="mage_translation_widget" xsi:type="string"><![CDATA[~(?:\$|jQuery)\.mage\.__\((?s)[^'"]*?(['"])(.+?)(?<!\\)\1(?s).*?\)~]]></item>
69+
<item name="mage_translation_static" xsi:type="string"><![CDATA[~\$t\((?s)[^'"]*?(["'])(.+?)\1(?s).*?\)~]]></item>
7070
</argument>
7171
</arguments>
7272
</type>

0 commit comments

Comments
 (0)