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

Commit 033d4b8

Browse files
MAGETWO-87524: [EngCom Team] Batch 32. Forwardports to 2.3-develop #1359
2 parents 8ded149 + 4340ef7 commit 033d4b8

File tree

22 files changed

+563
-26
lines changed

22 files changed

+563
-26
lines changed

app/bootstrap.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@
4949
unset($_SERVER['ORIG_PATH_INFO']);
5050
}
5151

52-
if (!empty($_SERVER['MAGE_PROFILER'])
52+
if (
53+
(!empty($_SERVER['MAGE_PROFILER']) || file_exists(BP . '/var/profiler.flag'))
5354
&& isset($_SERVER['HTTP_ACCEPT'])
5455
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
5556
) {
5657
\Magento\Framework\Profiler::applyConfig(
57-
$_SERVER['MAGE_PROFILER'],
58+
(isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])) ? $_SERVER['MAGE_PROFILER'] : trim(file_get_contents(BP . '/var/profiler.flag')),
5859
BP,
5960
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
6061
);

app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function processBundleOptionsData(\Magento\Catalog\Model\Product $prod
127127
}
128128
$options = [];
129129
foreach ($bundleOptionsData as $key => $optionData) {
130-
if ((bool)$optionData['delete']) {
130+
if (!empty($optionData['delete'])) {
131131
continue;
132132
}
133133

app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ protected function setUp()
5757
'setOptions',
5858
'setCanSaveBundleSelections',
5959
'__wakeup',
60-
'getOptionsReadonly'
60+
'getOptionsReadonly',
61+
'getBundleOptionsData',
62+
'getExtensionAttributes',
63+
'setExtensionAttributes',
6164
];
6265
$this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods);
6366
$optionInterfaceFactory = $this->getMockBuilder(\Magento\Bundle\Api\Data\OptionInterfaceFactory::class)
@@ -127,6 +130,17 @@ public function testAfterInitializeIfBundleAnsCustomOptionsAndBundleSelectionsEx
127130
);
128131
$this->productMock->expects($this->once())->method('setOptions')->with(null);
129132
$this->productMock->expects($this->once())->method('setCanSaveBundleSelections')->with(true);
133+
$this->productMock->expects($this->once())
134+
->method('getBundleOptionsData')
135+
->willReturn(['option_1' => ['delete' => 1]]);
136+
$extentionAttribute = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductExtensionInterface::class)
137+
->disableOriginalConstructor()
138+
->setMethods(['setBundleProductOptions'])
139+
->getMockForAbstractClass();
140+
$extentionAttribute->expects($this->once())->method('setBundleProductOptions')->with([]);
141+
$this->productMock->expects($this->once())->method('getExtensionAttributes')->willReturn($extentionAttribute);
142+
$this->productMock->expects($this->once())->method('setExtensionAttributes')->with($extentionAttribute);
143+
130144
$this->model->afterInitialize($this->subjectMock, $this->productMock);
131145
}
132146

app/code/Magento/Catalog/Model/Product/Option/Value.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Catalog\Model\Product;
1010
use Magento\Catalog\Model\Product\Option;
11+
use Magento\Catalog\Pricing\Price\BasePrice;
1112
use Magento\Framework\Model\AbstractModel;
1213

1314
/**
@@ -222,7 +223,7 @@ public function saveValues()
222223
public function getPrice($flag = false)
223224
{
224225
if ($flag && $this->getPriceType() == self::TYPE_PERCENT) {
225-
$basePrice = $this->getOption()->getProduct()->getFinalPrice();
226+
$basePrice = $this->getOption()->getProduct()->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getValue();
226227
$price = $basePrice * ($this->_getData(self::KEY_PRICE) / 100);
227228
return $price;
228229
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ private function getMockedValueCollectionFactory()
104104

105105
$mockBuilder =
106106
$this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class)
107-
->setMethods(['create'])
108-
->disableOriginalConstructor();
107+
->setMethods(['create'])
108+
->disableOriginalConstructor();
109109
$mock = $mockBuilder->getMock();
110110

111111
$mock->expects($this->any())
@@ -164,13 +164,27 @@ private function getMockedOption()
164164
private function getMockedProduct()
165165
{
166166
$mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
167-
->setMethods(['getFinalPrice', '__wakeup'])
167+
->setMethods(['getPriceInfo', '__wakeup'])
168168
->disableOriginalConstructor();
169169
$mock = $mockBuilder->getMock();
170170

171-
$mock->expects($this->any())
172-
->method('getFinalPrice')
173-
->will($this->returnValue(10));
171+
$priceInfoMock = $this->getMockForAbstractClass(
172+
\Magento\Framework\Pricing\PriceInfoInterface::class,
173+
[],
174+
'',
175+
false,
176+
false,
177+
true,
178+
['getPrice']
179+
);
180+
181+
$priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class);
182+
183+
$priceInfoMock->expects($this->any())->method('getPrice')->willReturn($priceMock);
184+
185+
$mock->expects($this->any())->method('getPriceInfo')->willReturn($priceInfoMock);
186+
187+
$priceMock->expects($this->any())->method('getValue')->willReturn(10);
174188

175189
return $mock;
176190
}

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CustomOptionsTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,16 @@ public function testModifyMeta()
154154
->method('getAll')
155155
->willReturn([]);
156156

157-
$this->assertArrayHasKey(CustomOptions::GROUP_CUSTOM_OPTIONS_NAME, $this->getModel()->modifyMeta([]));
157+
$meta = $this->getModel()->modifyMeta([]);
158+
159+
$this->assertArrayHasKey(CustomOptions::GROUP_CUSTOM_OPTIONS_NAME, $meta);
160+
161+
$buttonAdd = $meta['custom_options']['children']['container_header']['children']['button_add'];
162+
$buttonAddTargetName = $buttonAdd['arguments']['data']['config']['actions'][0]['targetName'];
163+
$expectedTargetName = '${ $.ns }.${ $.ns }.' . CustomOptions::GROUP_CUSTOM_OPTIONS_NAME
164+
. '.' . CustomOptions::GRID_OPTIONS_NAME;
165+
166+
$this->assertEquals($expectedTargetName, $buttonAddTargetName);
158167
}
159168

160169
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ protected function getHeaderContainerConfig($sortOrder)
348348
'sortOrder' => 20,
349349
'actions' => [
350350
[
351-
'targetName' => 'ns = ${ $.ns }, index = ' . static::GRID_OPTIONS_NAME,
351+
'targetName' => '${ $.ns }.${ $.ns }.' . static::GROUP_CUSTOM_OPTIONS_NAME
352+
. '.' . static::GRID_OPTIONS_NAME,
352353
'actionName' => 'processingAddChild',
353354
]
354355
]

app/code/Magento/Checkout/Model/Cart.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
/**
1515
* Shopping cart model
16+
*
1617
* @api
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18-
* @deprecated 100.1.0
19+
* @deprecated 100.1.0 Use \Magento\Quote\Model\Quote instead
20+
* @see \Magento\Quote\Api\Data\CartInterface
1921
*/
2022
class Cart extends DataObject implements CartInterface
2123
{

app/code/Magento/Checkout/Model/Cart/CartInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
*
1313
* @api
1414
* @author Magento Core Team <[email protected]>
15-
* @deprecated 100.1.0
15+
* @deprecated 100.1.0 Use \Magento\Quote\Api\Data\CartInterface instead
16+
* @see \Magento\Quote\Api\Data\CartInterface
1617
*/
1718
interface CartInterface
1819
{

app/code/Magento/Config/Model/Config/Structure/Reader.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,18 @@ protected function _readFiles($fileList)
124124
* Processing nodes of the document before merging
125125
*
126126
* @param string $content
127+
* @throws \Magento\Framework\Config\Dom\ValidationException
127128
* @return string
128129
*/
129130
protected function processingDocument($content)
130131
{
131132
$object = new DataObject();
132133
$document = new \DOMDocument();
133-
134-
$document->loadXML($content);
134+
try {
135+
$document->loadXML($content);
136+
} catch (\Exception $e) {
137+
throw new \Magento\Framework\Config\Dom\ValidationException($e->getMessage());
138+
}
135139
$this->compiler->compile($document->documentElement, $object, $object);
136140

137141
return $document->saveXML();

0 commit comments

Comments
 (0)