Skip to content

Commit 4b4847e

Browse files
committed
MAGETWO-57569: [Backport] Functional upgrade test fail 2.1.x --> 2.2.x - 2.2
2 parents 9a89564 + af1c56d commit 4b4847e

File tree

67 files changed

+877
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+877
-285
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function addMediaDataToProduct(Product $product, array $mediaEntries)
7878

7979
foreach ($mediaEntries as $mediaEntry) {
8080
$mediaEntry = $this->substituteNullsWithDefaultValues($mediaEntry);
81-
$value['images'][] = $mediaEntry;
81+
$value['images'][$mediaEntry['value_id']] = $mediaEntry;
8282
}
8383
$product->setData($attrCode, $value);
8484
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ protected function _getIndexableAttributesCondition()
263263
'ca.is_filterable_in_search > 0',
264264
'ca.is_visible_in_advanced_search > 0',
265265
'ca.is_filterable > 0',
266+
// Visibility is attribute that isn't used by search, but required to determine is product should be shown
267+
"ea.attribute_code = 'visibility'"
266268
];
267269

268270
return implode(' OR ', $conditions);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Magento\Catalog\Model\Locator\LocatorInterface;
1010
use Magento\Ui\Component\Form;
1111
use Magento\Framework\Stdlib\ArrayManager;
12-
use Magento\Store\Model\StoreManagerInterface;
13-
use Magento\Framework\Locale\CurrencyInterface;
1412

1513
/**
1614
* Data provider for main panel of product page
@@ -26,14 +24,9 @@ class General extends AbstractModifier
2624
* @var ArrayManager
2725
*/
2826
protected $arrayManager;
29-
30-
/**
31-
* @var StoreManagerInterface
32-
*/
33-
private $storeManager;
3427

3528
/**
36-
* @var CurrencyInterface
29+
* @var \Magento\Framework\Locale\CurrencyInterface
3730
*/
3831
private $localeCurrency;
3932

@@ -82,7 +75,7 @@ protected function customizeWeightFormat(array $data)
8275
$data = $this->arrayManager->replace(
8376
$path,
8477
$data,
85-
$this->formatNumber($this->arrayManager->get($path, $data))
78+
$this->formatWeight($this->arrayManager->get($path, $data))
8679
);
8780
}
8881

@@ -105,7 +98,7 @@ protected function customizeAdvancedPriceFormat(array $data)
10598
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
10699
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
107100
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
108-
$this->formatNumber((int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]);
101+
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
109102
}
110103
}
111104

@@ -373,28 +366,12 @@ protected function customizeNameListeners(array $meta)
373366
private function getLocaleCurrency()
374367
{
375368
if ($this->localeCurrency === null) {
376-
$this->localeCurrency = \Magento\Framework\App\ObjectManager::getInstance()->get(CurrencyInterface::class);
369+
$this->localeCurrency = \Magento\Framework\App\ObjectManager::getInstance()
370+
->get(\Magento\Framework\Locale\CurrencyInterface::class);
377371
}
378372
return $this->localeCurrency;
379373
}
380374

381-
/**
382-
* The getter function to get the store manager for real application code
383-
*
384-
* @return \Magento\Store\Model\StoreManagerInterface
385-
*
386-
* @deprecated
387-
*/
388-
private function getStoreManager()
389-
{
390-
if ($this->storeManager === null) {
391-
$this->storeManager =
392-
\Magento\Framework\App\ObjectManager::getInstance()->get(StoreManagerInterface::class);
393-
}
394-
return $this->storeManager;
395-
}
396-
397-
398375
/**
399376
* Format price according to the locale of the currency
400377
*
@@ -407,7 +384,7 @@ protected function formatPrice($value)
407384
return null;
408385
}
409386

410-
$store = $this->getStoreManager()->getStore();
387+
$store = $this->locator->getStore();
411388
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
412389
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
413390

@@ -428,7 +405,7 @@ protected function formatNumber($value)
428405

429406
$value = (float)$value;
430407
$precision = strlen(substr(strrchr($value, "."), 1));
431-
$store = $this->getStoreManager()->getStore();
408+
$store = $this->locator->getStore();
432409
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
433410
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL,
434411
'precision' => $precision]);

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
define([
67
'jquery',
78
'Magento_Catalog/js/price-utils',
@@ -29,6 +30,7 @@ define([
2930
*/
3031
_init: function initPriceBox() {
3132
var box = this.element;
33+
3234
box.trigger('updatePrice');
3335
this.cache.displayPrices = utils.deepClone(this.options.prices);
3436
},
@@ -70,7 +72,8 @@ define([
7072
updatePrice: function updatePrice(newPrices) {
7173
var prices = this.cache.displayPrices,
7274
additionalPrice = {},
73-
pricesCode = [];
75+
pricesCode = [],
76+
priceValue, origin, finalPrice;
7477

7578
this.cache.additionalPriceObject = this.cache.additionalPriceObject || {};
7679

@@ -89,19 +92,19 @@ define([
8992
pricesCode = _.keys(additional);
9093
}
9194
_.each(pricesCode, function (priceCode) {
92-
var priceValue = additional[priceCode] || {};
95+
priceValue = additional[priceCode] || {};
9396
priceValue.amount = +priceValue.amount || 0;
9497
priceValue.adjustments = priceValue.adjustments || {};
9598

9699
additionalPrice[priceCode] = additionalPrice[priceCode] || {
97-
'amount': 0,
98-
'adjustments': {}
99-
};
100-
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0)
101-
+ priceValue.amount;
100+
'amount': 0,
101+
'adjustments': {}
102+
};
103+
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0) +
104+
priceValue.amount;
102105
_.each(priceValue.adjustments, function (adValue, adCode) {
103-
additionalPrice[priceCode].adjustments[adCode] = 0
104-
+ (additionalPrice[priceCode].adjustments[adCode] || 0) + adValue;
106+
additionalPrice[priceCode].adjustments[adCode] = 0 +
107+
(additionalPrice[priceCode].adjustments[adCode] || 0) + adValue;
105108
});
106109
});
107110
});
@@ -110,23 +113,24 @@ define([
110113
this.cache.displayPrices = utils.deepClone(this.options.prices);
111114
} else {
112115
_.each(additionalPrice, function (option, priceCode) {
113-
var origin = this.options.prices[priceCode] || {},
114-
final = prices[priceCode] || {};
116+
origin = this.options.prices[priceCode] || {};
117+
finalPrice = prices[priceCode] || {};
115118
option.amount = option.amount || 0;
116119
origin.amount = origin.amount || 0;
117120
origin.adjustments = origin.adjustments || {};
118-
final.adjustments = final.adjustments || {};
121+
finalPrice.adjustments = finalPrice.adjustments || {};
119122

120-
final.amount = 0 + origin.amount + option.amount;
123+
finalPrice.amount = 0 + origin.amount + option.amount;
121124
_.each(option.adjustments, function (pa, paCode) {
122-
final.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa;
125+
finalPrice.adjustments[paCode] = 0 + (origin.adjustments[paCode] || 0) + pa;
123126
});
124127
}, this);
125128
}
126129

127130
this.element.trigger('reloadPrice');
128131
},
129132

133+
/*eslint-disable no-extra-parens*/
130134
/**
131135
* Render price unit block.
132136
*/
@@ -135,16 +139,19 @@ define([
135139
priceTemplate = mageTemplate(this.options.priceTemplate);
136140

137141
_.each(this.cache.displayPrices, function (price, priceCode) {
138-
price.final = _.reduce(price.adjustments, function(memo, amount) {
142+
price.final = _.reduce(price.adjustments, function (memo, amount) {
139143
return memo + amount;
140144
}, price.amount);
141145

142146
price.formatted = utils.formatPrice(price.final, priceFormat);
143147

144-
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price}));
148+
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({
149+
data: price
150+
}));
145151
}, this);
146152
},
147153

154+
/*eslint-enable no-extra-parens*/
148155
/**
149156
* Overwrites initial (default) prices object.
150157
* @param {Object} prices
@@ -177,6 +184,7 @@ define([
177184
var box = this.element,
178185
priceHolders = $('[data-price-type]', box),
179186
prices = this.options.prices;
187+
180188
this.options.productId = box.data('productId');
181189

182190
if (_.isEmpty(prices)) {
@@ -199,10 +207,7 @@ define([
199207
_setDefaultsFromPriceConfig: function _setDefaultsFromPriceConfig() {
200208
var config = this.options.priceConfig;
201209

202-
if (config) {
203-
if (+config.productId !== +this.options.productId) {
204-
return;
205-
}
210+
if (config && config.prices) {
206211
this.options.prices = config.prices;
207212
}
208213
}

app/code/Magento/CatalogImportExport/Model/Import/Uploader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ public function move($fileName, $renameFileOff = false)
155155

156156
$filePath = $this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName);
157157
$this->_setUploadFile($filePath);
158-
$result = $this->save($this->getDestDir());
158+
$destDir = $this->_directory->getAbsolutePath($this->getDestDir());
159+
$result = $this->save($destDir);
159160
$result['name'] = self::getCorrectFileName($result['name']);
160161
return $result;
161162
}
@@ -305,11 +306,10 @@ protected function _moveFile($tmpPath, $destPath)
305306
$tmpRealPath = $this->_directory->getDriver()->getRealPath(
306307
$this->_directory->getAbsolutePath($tmpPath)
307308
);
308-
$destinationRealPath = $this->_directory->getDriver()->getRealPath(
309-
$this->_directory->getAbsolutePath($destPath)
310-
);
309+
$destinationRealPath = $this->_directory->getDriver()->getRealPath($destPath);
310+
$relativeDestPath = $this->_directory->getRelativePath($destPath);
311311
$isSameFile = $tmpRealPath === $destinationRealPath;
312-
return $isSameFile ?: $this->_directory->copyFile($tmpPath, $destPath);
312+
return $isSameFile ?: $this->_directory->copyFile($tmpPath, $relativeDestPath);
313313
} else {
314314
return false;
315315
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ protected function setUp()
6868

6969
$this->readFactory = $this->getMockBuilder(\Magento\Framework\Filesystem\File\ReadFactory::class)
7070
->disableOriginalConstructor()
71+
->setMethods(['create'])
7172
->getMock();
7273

7374
$this->directoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Writer::class)
74-
->setMethods(['writeFile', 'getRelativePath'])
75+
->setMethods(['writeFile', 'getRelativePath', 'isWritable', 'getAbsolutePath'])
7576
->disableOriginalConstructor()
7677
->getMock();
7778

@@ -92,6 +93,7 @@ protected function setUp()
9293
$this->filesystem,
9394
$this->readFactory,
9495
])
96+
->setMethods(['_setUploadFile', 'save', 'getTmpDir'])
9597
->getMock();
9698
}
9799

@@ -100,10 +102,14 @@ protected function setUp()
100102
*/
101103
public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName)
102104
{
105+
$destDir = 'var/dest/dir';
103106
$expectedRelativeFilePath = $this->uploader->getTmpDir() . '/' . $expectedFileName;
107+
$this->directoryMock->expects($this->once())->method('isWritable')->with($destDir)->willReturn(true);
104108
$this->directoryMock->expects($this->any())->method('getRelativePath')->with($expectedRelativeFilePath);
109+
$this->directoryMock->expects($this->once())->method('getAbsolutePath')->with($destDir)
110+
->willReturn($destDir . '/' . $expectedFileName);
105111
// Check writeFile() method invoking.
106-
$this->directoryMock->expects($this->any())->method('writeFile')->will($this->returnValue(null));
112+
$this->directoryMock->expects($this->any())->method('writeFile')->will($this->returnValue($expectedFileName));
107113

108114
// Create adjusted reader which does not validate path.
109115
$readMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\Read::class)
@@ -113,59 +119,37 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName)
113119
// Check readAll() method invoking.
114120
$readMock->expects($this->once())->method('readAll')->will($this->returnValue(null));
115121

116-
$this->readFactory = $this->getMockBuilder(\Magento\Framework\Filesystem\File\ReadFactory::class)
117-
->disableOriginalConstructor()
118-
->setMethods(['create'])
119-
->getMock();
120122
// Check create() method invoking with expected argument.
121123
$this->readFactory->expects($this->once())
122124
->method('create')
123125
->will($this->returnValue($readMock))->with($expectedHost);
124-
125-
$uploaderMock = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
126-
->setConstructorArgs([
127-
$this->coreFileStorageDb,
128-
$this->coreFileStorage,
129-
$this->imageFactory,
130-
$this->validator,
131-
$this->filesystem,
132-
$this->readFactory,
133-
])
134-
->setMethods(['_setUploadFile', 'save', 'getTmpDir'])
135-
->getMock();
136-
137126
//Check invoking of getTmpDir(), _setUploadFile(), save() methods.
138-
$uploaderMock->expects($this->any())->method('getTmpDir')->will($this->returnValue(''));
139-
$uploaderMock->expects($this->once())->method('_setUploadFile')->will($this->returnSelf());
140-
$uploaderMock->expects($this->once())->method('save')->will($this->returnValue(['name' => null]));
127+
$this->uploader->expects($this->any())->method('getTmpDir')->will($this->returnValue(''));
128+
$this->uploader->expects($this->once())->method('_setUploadFile')->will($this->returnSelf());
129+
$this->uploader->expects($this->once())->method('save')->with($destDir . '/' . $expectedFileName)
130+
->willReturn(['name' => $expectedFileName]);
141131

142-
$uploaderMock->move($fileUrl);
132+
$this->uploader->setDestDir($destDir);
133+
$this->assertEquals(['name' => $expectedFileName], $this->uploader->move($fileUrl));
143134
}
144135

145136
public function testMoveFileName()
146137
{
138+
$destDir = 'var/dest/dir';
147139
$fileName = 'test_uploader_file';
148140
$expectedRelativeFilePath = $this->uploader->getTmpDir() . '/' . $fileName;
141+
$this->directoryMock->expects($this->once())->method('isWritable')->with($destDir)->willReturn(true);
149142
$this->directoryMock->expects($this->any())->method('getRelativePath')->with($expectedRelativeFilePath);
150-
151-
$uploaderMock = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
152-
->setConstructorArgs([
153-
$this->coreFileStorageDb,
154-
$this->coreFileStorage,
155-
$this->imageFactory,
156-
$this->validator,
157-
$this->filesystem,
158-
$this->readFactory,
159-
])
160-
->setMethods(['_setUploadFile', 'save', 'getTmpDir'])
161-
->getMock();
162-
143+
$this->directoryMock->expects($this->once())->method('getAbsolutePath')->with($destDir)
144+
->willReturn($destDir . '/' . $fileName);
163145
//Check invoking of getTmpDir(), _setUploadFile(), save() methods.
164-
$uploaderMock->expects($this->once())->method('getTmpDir')->will($this->returnValue(''));
165-
$uploaderMock->expects($this->once())->method('_setUploadFile')->will($this->returnSelf());
166-
$uploaderMock->expects($this->once())->method('save')->will($this->returnValue(['name' => null]));
146+
$this->uploader->expects($this->once())->method('getTmpDir')->will($this->returnValue(''));
147+
$this->uploader->expects($this->once())->method('_setUploadFile')->will($this->returnSelf());
148+
$this->uploader->expects($this->once())->method('save')->with($destDir . '/' . $fileName)
149+
->willReturn(['name' => $fileName]);
167150

168-
$uploaderMock->move($fileName);
151+
$this->uploader->setDestDir($destDir);
152+
$this->assertEquals(['name' => $fileName], $this->uploader->move($fileName));
169153
}
170154

171155
public function moveFileUrlDataProvider()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function addFieldToFilter($field, $condition = null)
265265

266266
$this->getSearchCriteriaBuilder();
267267
$this->getFilterBuilder();
268-
if (!is_array($condition) || !in_array(key($condition), ['from', 'to'])) {
268+
if (!is_array($condition) || !in_array(key($condition), ['from', 'to'], true)) {
269269
$this->filterBuilder->setField($field);
270270
$this->filterBuilder->setValue($condition);
271271
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
@@ -371,7 +371,7 @@ protected function _renderFilters()
371371
public function setOrder($attribute, $dir = Select::SQL_DESC)
372372
{
373373
$this->order = ['field' => $attribute, 'dir' => $dir];
374-
if ($attribute != 'relevance') {
374+
if ($attribute !== 'relevance') {
375375
parent::setOrder($attribute, $dir);
376376
}
377377
return $this;

0 commit comments

Comments
 (0)