Skip to content

Commit 4b3fce3

Browse files
committed
Merge branch '2.3-develop-mainline' into MC-29938_1
2 parents c2004dd + 130b479 commit 4b3fce3

File tree

72 files changed

+1962
-524
lines changed

Some content is hidden

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

72 files changed

+1962
-524
lines changed

app/code/Magento/Backend/Block/Media/Uploader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _construct()
8787

8888
$this->setId($this->getId() . '_Uploader');
8989

90-
$uploadUrl = $this->_urlBuilder->addSessionParam()->getUrl('adminhtml/*/upload');
90+
$uploadUrl = $this->_urlBuilder->getUrl('adminhtml/*/upload');
9191
$this->getConfig()->setUrl($uploadUrl);
9292
$this->getConfig()->setParams(['form_key' => $this->getFormKey()]);
9393
$this->getConfig()->setFileField('file');

app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ protected function setUp()
4545
$this->locatorMock = $this->getMockBuilder(LocatorInterface::class)
4646
->getMockForAbstractClass();
4747
$this->productMock = $this->getMockBuilder(ProductInterface::class)
48+
->setMethods(['getPriceType'])
4849
->getMockForAbstractClass();
4950

5051
$this->locatorMock->expects($this->any())
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Bundle\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
7+
8+
use Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\BundlePrice;
9+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
10+
use Magento\Framework\Stdlib\ArrayManager;
11+
12+
class BundlePriceTest extends AbstractModifierTest
13+
{
14+
/**
15+
* @return BundlePrice
16+
*/
17+
protected function createModel()
18+
{
19+
return $this->objectManager->getObject(
20+
BundlePrice::class,
21+
[
22+
'locator' => $this->locatorMock,
23+
'arrayManager' => $this->arrayManagerMock
24+
]
25+
);
26+
}
27+
28+
/**
29+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
30+
*/
31+
public function testModifyMeta()
32+
{
33+
$this->productMock->expects($this->any())
34+
->method('getId')
35+
->willReturn(true);
36+
$this->productMock->expects($this->any())
37+
->method('getPriceType')
38+
->willReturn(0);
39+
$priceTypePath = 'bundle-items/children/' . BundlePrice::CODE_PRICE_TYPE;
40+
$priceTypeConfigPath = $priceTypePath . BundlePrice::META_CONFIG_PATH;
41+
$pricePath = 'product-details/children/' . ProductAttributeInterface::CODE_PRICE;
42+
$priceConfigPath = $pricePath . BundlePrice::META_CONFIG_PATH;
43+
$sourceMeta = [
44+
'bundle-items' => [
45+
'children' => [
46+
BundlePrice::CODE_PRICE_TYPE => []
47+
]
48+
]
49+
];
50+
$priceTypeParams = [
51+
'disabled' => true,
52+
'valueMap' => [
53+
'false' => '1',
54+
'true' => '0'
55+
],
56+
'validation' => [
57+
'required-entry' => false
58+
]
59+
];
60+
$priceTypeMeta = [
61+
'bundle-items' => [
62+
'children' => [
63+
BundlePrice::CODE_PRICE_TYPE => $priceTypeParams
64+
]
65+
]
66+
];
67+
$priceParams = [
68+
'imports' => [
69+
'disabled' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked'
70+
]
71+
];
72+
$priceMeta = [
73+
'product-details' => [
74+
'children' => [
75+
BundlePrice::CODE_PRICE_TYPE => []
76+
]
77+
],
78+
'bundle-items' => [
79+
'children' => [
80+
ProductAttributeInterface::CODE_PRICE => $priceParams
81+
]
82+
]
83+
];
84+
$taxParams = [
85+
'service' => [
86+
'template' => ''
87+
]
88+
];
89+
90+
$this->arrayManagerMock->expects(static::any())
91+
->method('findPath')
92+
->willReturnMap(
93+
[
94+
[
95+
BundlePrice::CODE_PRICE_TYPE,
96+
$sourceMeta,
97+
null,
98+
'children',
99+
ArrayManager::DEFAULT_PATH_DELIMITER,
100+
$priceTypePath
101+
],
102+
[
103+
ProductAttributeInterface::CODE_PRICE,
104+
$priceTypeMeta,
105+
BundlePrice::DEFAULT_GENERAL_PANEL . '/children',
106+
'children',
107+
ArrayManager::DEFAULT_PATH_DELIMITER,
108+
$pricePath
109+
],
110+
[
111+
BundlePrice::CODE_TAX_CLASS_ID,
112+
$priceMeta,
113+
null,
114+
'children',
115+
ArrayManager::DEFAULT_PATH_DELIMITER,
116+
$pricePath
117+
],
118+
[
119+
BundlePrice::CODE_TAX_CLASS_ID,
120+
$priceMeta,
121+
null,
122+
'children',
123+
ArrayManager::DEFAULT_PATH_DELIMITER,
124+
$pricePath
125+
]
126+
]
127+
);
128+
$this->arrayManagerMock->expects($this->exactly(4))
129+
->method('merge')
130+
->willReturnMap(
131+
[
132+
[
133+
$priceTypeConfigPath,
134+
$sourceMeta,
135+
$priceTypeParams,
136+
ArrayManager::DEFAULT_PATH_DELIMITER,
137+
$priceTypeMeta
138+
],
139+
[
140+
$priceConfigPath,
141+
$priceTypeMeta,
142+
$priceParams,
143+
ArrayManager::DEFAULT_PATH_DELIMITER,
144+
$priceMeta
145+
],
146+
[
147+
$priceConfigPath,
148+
$priceMeta,
149+
$priceParams,
150+
ArrayManager::DEFAULT_PATH_DELIMITER,
151+
$priceMeta
152+
],
153+
[
154+
$priceConfigPath,
155+
$priceMeta,
156+
$taxParams,
157+
ArrayManager::DEFAULT_PATH_DELIMITER,
158+
$priceMeta
159+
]
160+
]
161+
);
162+
163+
$this->assertSame($priceMeta, $this->getModel()->modifyMeta($sourceMeta));
164+
}
165+
166+
public function testModifyData()
167+
{
168+
$expectedData = [];
169+
$this->assertEquals($expectedData, $this->getModel()->modifyData($expectedData));
170+
}
171+
}

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier;
77

8+
use Magento\Bundle\Model\Product\Price;
89
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
910
use Magento\Catalog\Api\Data\ProductAttributeInterface;
1011
use Magento\Framework\Stdlib\ArrayManager;
@@ -39,7 +40,7 @@ public function __construct(
3940
$this->locator = $locator;
4041
$this->arrayManager = $arrayManager;
4142
}
42-
43+
4344
/**
4445
* @inheritdoc
4546
*/
@@ -89,7 +90,22 @@ public function modifyMeta(array $meta)
8990
]
9091
]
9192
);
92-
93+
if ($this->locator->getProduct()->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
94+
$meta = $this->arrayManager->merge(
95+
$this->arrayManager->findPath(
96+
static::CODE_TAX_CLASS_ID,
97+
$meta,
98+
null,
99+
'children'
100+
) . static::META_CONFIG_PATH,
101+
$meta,
102+
[
103+
'service' => [
104+
'template' => ''
105+
]
106+
]
107+
);
108+
}
93109
return $meta;
94110
}
95111

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function _prepareLayout()
9595
);
9696

9797
$this->getUploader()->getConfig()->setUrl(
98-
$this->_urlBuilder->addSessionParam()->getUrl('catalog/product_gallery/upload')
98+
$this->_urlBuilder->getUrl('catalog/product_gallery/upload')
9999
)->setFileField(
100100
'image'
101101
)->setFilters(

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ protected function _applyTierPrice($product, $qty, $finalPrice)
262262

263263
$tierPrice = $product->getTierPrice($qty);
264264
if (is_numeric($tierPrice)) {
265-
$finalPrice = min($finalPrice, $tierPrice);
265+
$finalPrice = min($finalPrice, (float) $tierPrice);
266266
}
267267
return $finalPrice;
268268
}
@@ -645,7 +645,7 @@ public function calculateSpecialPrice(
645645
) {
646646
if ($specialPrice !== null && $specialPrice != false) {
647647
if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
648-
$finalPrice = min($finalPrice, $specialPrice);
648+
$finalPrice = min($finalPrice, (float) $specialPrice);
649649
}
650650
}
651651
return $finalPrice;

app/code/Magento/Catalog/Model/Product/Url.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,10 @@ public function getUrlInStore(\Magento\Catalog\Model\Product $product, $params =
101101
*/
102102
public function getProductUrl($product, $useSid = null)
103103
{
104-
if ($useSid === null) {
105-
$useSid = $this->sidResolver->getUseSessionInUrl();
106-
}
107-
108104
$params = [];
109105
if (!$useSid) {
110106
$params['_nosid'] = true;
111107
}
112-
113108
return $this->getUrl($product, $params);
114109
}
115110

app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,11 @@ public function testGetUrl(
159159
$this->assertEquals($requestPathProduct, $this->model->getUrlInStore($product, $routeParams));
160160
break;
161161
case 'getProductUrl':
162-
$this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, true));
162+
$this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, null));
163163
$this->sidResolver
164-
->expects($this->once())
164+
->expects($this->never())
165165
->method('getUseSessionInUrl')
166166
->will($this->returnValue(true));
167-
$this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, null));
168167
break;
169168
}
170169
}
@@ -212,7 +211,7 @@ public function getUrlDataProvider()
212211
1,
213212
1,
214213
[],
215-
['_direct' => '/product/url/path', '_query' => []],
214+
['_direct' => '/product/url/path', '_query' => [], '_nosid' => true],
216215
null,
217216
null,
218217
]

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Magento\Framework\App\RequestInterface;
1212
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
1313
use Magento\Framework\DB\Select as DbSelect;
14+
use Magento\Framework\EntityManager\MetadataPool;
15+
use Magento\Framework\EntityManager\EntityMetadataInterface;
16+
use Magento\Ui\DataProvider\Modifier\PoolInterface;
1417

1518
class ProductCustomOptionsDataProviderTest extends \PHPUnit\Framework\TestCase
1619
{
@@ -44,6 +47,21 @@ class ProductCustomOptionsDataProviderTest extends \PHPUnit\Framework\TestCase
4447
*/
4548
protected $dbSelectMock;
4649

50+
/**
51+
* @var MetadataPool|\PHPUnit_Framework_MockObject_MockObject
52+
*/
53+
private $metadataPool;
54+
55+
/**
56+
* @var EntityMetadataInterface|\PHPUnit_Framework_MockObject_MockObject
57+
*/
58+
private $entityMetadata;
59+
60+
/**
61+
* @var PoolInterface|\PHPUnit_Framework_MockObject_MockObject
62+
*/
63+
private $modifiersPool;
64+
4765
protected function setUp()
4866
{
4967
$this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
@@ -73,12 +91,29 @@ protected function setUp()
7391
->method('create')
7492
->willReturn($this->collectionMock);
7593

94+
$this->modifiersPool = $this->getMockBuilder(PoolInterface::class)
95+
->getMockForAbstractClass();
96+
$this->entityMetadata = $this->getMockBuilder(EntityMetadataInterface::class)
97+
->getMockForAbstractClass();
98+
$this->entityMetadata->expects($this->any())
99+
->method('getLinkField')
100+
->willReturn('entity_id');
101+
$this->metadataPool = $this->getMockBuilder(MetadataPool::class)
102+
->disableOriginalConstructor()
103+
->setMethods(['getMetadata'])
104+
->getMock();
105+
$this->metadataPool->expects($this->any())
106+
->method('getMetadata')
107+
->willReturn($this->entityMetadata);
108+
76109
$this->objectManagerHelper = new ObjectManagerHelper($this);
77110
$this->dataProvider = $this->objectManagerHelper->getObject(
78111
ProductCustomOptionsDataProvider::class,
79112
[
80113
'collectionFactory' => $this->collectionFactoryMock,
81-
'request' => $this->requestMock
114+
'request' => $this->requestMock,
115+
'modifiersPool' => $this->modifiersPool,
116+
'metadataPool' => $this->metadataPool
82117
]
83118
);
84119
}

0 commit comments

Comments
 (0)