Skip to content

Commit 863a308

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-lynx/magento2ce into jquery-upgrade
2 parents 84a457b + 5dcb5a5 commit 863a308

File tree

18 files changed

+565
-74
lines changed

18 files changed

+565
-74
lines changed

app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function execute(array $cartItemData): array
9393
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
9494
}
9595

96-
$this->checkProductStock($sku, (float) $qty, (int) $cart->getStore()->getWebsite()->getId());
96+
$this->checkProductStock($sku, (float) $qty, (int) $cart->getStore()->getWebsiteId());
9797

9898
$configurableProductLinks = $parentProduct->getExtensionAttributes()->getConfigurableProductLinks();
9999
if (!in_array($product->getId(), $configurableProductLinks)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProductGraphQl\Test\Unit\Model\Cart\BuyRequest;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Product;
12+
use Magento\CatalogInventory\Api\StockStateInterface;
13+
use Magento\ConfigurableProductGraphQl\Model\Cart\BuyRequest\SuperAttributeDataProvider;
14+
use Magento\ConfigurableProductGraphQl\Model\Options\Collection as OptionCollection;
15+
use Magento\Framework\EntityManager\MetadataPool;
16+
use Magento\Framework\Stdlib\ArrayManager;
17+
use Magento\Quote\Model\Quote;
18+
use Magento\Store\Api\Data\StoreInterface;
19+
use PHPUnit\Framework\MockObject\MockObject;
20+
use PHPUnit\Framework\TestCase;
21+
22+
/**
23+
* Test for SuperAttributeDataProvider
24+
*/
25+
class SuperAttributeDataProviderTest extends TestCase
26+
{
27+
/**
28+
* @var ArrayManager|MockObject
29+
*/
30+
private $arrayManager;
31+
32+
/**
33+
* @var ProductRepositoryInterface|MockObject
34+
*/
35+
private $productRepository;
36+
37+
/**
38+
* @var OptionCollection|MockObject
39+
*/
40+
private $optionCollection;
41+
42+
/**
43+
* @var MetadataPool|MockObject
44+
*/
45+
private $metadataPool;
46+
47+
/**
48+
* @var StockStateInterface|MockObject
49+
*/
50+
private $stockState;
51+
52+
/**
53+
* @var SuperAttributeDataProvider|MockObject
54+
*/
55+
private $superAttributeDataProvider;
56+
57+
/**
58+
* @inheritDoc
59+
*/
60+
protected function setUp(): void
61+
{
62+
$this->arrayManager = $this->getMockBuilder(ArrayManager::class)
63+
->disableOriginalConstructor()
64+
->getMock();
65+
$this->productRepository = $this->getMockBuilder(ProductRepositoryInterface::class)
66+
->disableOriginalConstructor()
67+
->getMockForAbstractClass();
68+
$this->optionCollection = $this->createMock(OptionCollection::class);
69+
$this->metadataPool = $this->getMockBuilder(MetadataPool::class)
70+
->disableOriginalConstructor()
71+
->onlyMethods(['getMetadata'])
72+
->addMethods(['getLinkField'])
73+
->getMock();
74+
$this->stockState = $this->getMockBuilder(StockStateInterface::class)
75+
->disableOriginalConstructor()
76+
->addMethods(['getHasError'])
77+
->getMockForAbstractClass();
78+
79+
$this->superAttributeDataProvider = new SuperAttributeDataProvider(
80+
$this->arrayManager,
81+
$this->productRepository,
82+
$this->optionCollection,
83+
$this->metadataPool,
84+
$this->stockState
85+
);
86+
}
87+
88+
/**
89+
* Check that website id is correctly retrieved
90+
*/
91+
public function testExecute(): void
92+
{
93+
$quoteMock = $this->getMockBuilder(Quote::class)
94+
->disableOriginalConstructor()
95+
->getMock();
96+
$cartItemData = [
97+
'data' => [
98+
'quantity' => 2.0,
99+
'sku' => 'simple1',
100+
],
101+
'parent_sku' => 'configurable',
102+
'model' => $quoteMock,
103+
];
104+
105+
$this->arrayManager->method('get')
106+
->withConsecutive(
107+
['parent_sku', $cartItemData],
108+
['data/sku', $cartItemData],
109+
['data/quantity', $cartItemData],
110+
['model', $cartItemData],
111+
)
112+
->willReturnOnConsecutiveCalls(
113+
'configurable',
114+
'simple1',
115+
2.0,
116+
$quoteMock,
117+
);
118+
119+
$storeMock = $this->getMockBuilder(StoreInterface::class)
120+
->disableOriginalConstructor()
121+
->addMethods(['getWebsite'])
122+
->getMockForAbstractClass();
123+
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
124+
$storeMock->expects($this->never())->method('getWebsite');
125+
$quoteMock->expects($this->atLeastOnce())
126+
->method('getStore')
127+
->willReturn($storeMock);
128+
129+
$productMock = $this->getMockBuilder(Product::class)
130+
->disableOriginalConstructor()
131+
->onlyMethods(['getId', 'getExtensionAttributes', 'getData'])
132+
->addMethods(['getConfigurableProductLinks'])
133+
->getMock();
134+
$productMock->method('getId')
135+
->willReturn(1);
136+
$productMock->method('getExtensionAttributes')
137+
->willReturnSelf();
138+
$productMock->method('getConfigurableProductLinks')
139+
->willReturn([1]);
140+
$productMock->method('getData')
141+
->willReturn(1);
142+
$this->productRepository->method('get')
143+
->willReturn($productMock);
144+
$this->stockState->method('checkQuoteItemQty')
145+
->willReturnSelf();
146+
$this->stockState->method('getHasError')
147+
->willReturn(false);
148+
$this->metadataPool->method('getMetadata')
149+
->willReturnSelf();
150+
$this->metadataPool->method('getLinkField')
151+
->willReturnSelf();
152+
$this->optionCollection->method('getAttributesByProductId')
153+
->willReturn([
154+
[
155+
'attribute_code' => 'code',
156+
'attribute_id' => 1,
157+
'values' => [['value_index' => 1]],
158+
]
159+
]);
160+
161+
$this->assertEquals(['super_attribute' => [1 => 1]], $this->superAttributeDataProvider->execute($cartItemData));
162+
}
163+
}

app/code/Magento/Customer/Controller/Adminhtml/File/Customer/Upload.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Psr\Log\LoggerInterface;
1616

17+
/**
18+
* Class for upload customer file attribute
19+
*/
1720
class Upload extends Action
1821
{
1922
/**
@@ -38,6 +41,11 @@ class Upload extends Action
3841
*/
3942
private $logger;
4043

44+
/**
45+
* @var string
46+
*/
47+
private $scope;
48+
4149
/**
4250
* @param Context $context
4351
* @param FileUploaderFactory $fileUploaderFactory
@@ -65,15 +73,15 @@ public function execute()
6573
if (empty($_FILES)) {
6674
throw new \Exception('$_FILES array is empty.');
6775
}
68-
69-
$attributeCode = key($_FILES['customer']['name']);
76+
$scope = array_key_first($_FILES);
77+
$attributeCode = key($_FILES[$scope]['name']);
7078
$attributeMetadata = $this->customerMetadataService->getAttributeMetadata($attributeCode);
7179

7280
/** @var FileUploader $fileUploader */
7381
$fileUploader = $this->fileUploaderFactory->create([
7482
'attributeMetadata' => $attributeMetadata,
7583
'entityTypeCode' => CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
76-
'scope' => 'customer',
84+
'scope' => $scope,
7785
]);
7886

7987
$errors = $fileUploader->validate();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="CliIndexerSetRealtimeModeActionGroup">
11+
<annotations>
12+
<description>Set indexers to realtime mode.</description>
13+
</annotations>
14+
15+
<magentoCLI command="indexer:set-mode" arguments="realtime" stepKey="setRealtimeIndexerMode"/>
16+
</actionGroup>
17+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="CliIndexerSetScheduleModeActionGroup">
11+
<annotations>
12+
<description>Set indexers to schedule mode.</description>
13+
</annotations>
14+
15+
<magentoCLI command="indexer:set-mode" arguments="schedule" stepKey="setScheduleIndexerMode"/>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/Sales/Model/Order.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
use Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection as TrackCollection;
3232
use Magento\Sales\Model\ResourceModel\Order\Status\History\Collection as HistoryCollection;
3333
use Magento\Store\Model\ScopeInterface;
34+
use Magento\Framework\App\Area;
35+
use Magento\Sales\Model\Order\StatusLabel;
3436

3537
/**
3638
* Order model
@@ -324,6 +326,11 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface
324326
*/
325327
private $regionResource;
326328

329+
/**
330+
* @var StatusLabel
331+
*/
332+
private $statusLabel;
333+
327334
/**
328335
* @param \Magento\Framework\Model\Context $context
329336
* @param \Magento\Framework\Registry $registry
@@ -395,7 +402,8 @@ public function __construct(
395402
SearchCriteriaBuilder $searchCriteriaBuilder = null,
396403
ScopeConfigInterface $scopeConfig = null,
397404
RegionFactory $regionFactory = null,
398-
RegionResource $regionResource = null
405+
RegionResource $regionResource = null,
406+
StatusLabel $statusLabel = null
399407
) {
400408
$this->_storeManager = $storeManager;
401409
$this->_orderConfig = $orderConfig;
@@ -427,7 +435,7 @@ public function __construct(
427435
$this->regionFactory = $regionFactory ?: ObjectManager::getInstance()->get(RegionFactory::class);
428436
$this->regionResource = $regionResource ?: ObjectManager::getInstance()->get(RegionResource::class);
429437
$this->regionItems = [];
430-
438+
$this->statusLabel = $statusLabel ?: ObjectManager::getInstance()->get(StatusLabel::class);
431439
parent::__construct(
432440
$context,
433441
$registry,
@@ -1104,7 +1112,11 @@ public function setState($state)
11041112
*/
11051113
public function getFrontendStatusLabel()
11061114
{
1107-
return $this->getConfig()->getStatusFrontendLabel($this->getStatus());
1115+
return $this->statusLabel->getStatusFrontendLabel(
1116+
$this->getStatus(),
1117+
Area::AREA_FRONTEND,
1118+
$this->getStoreId()
1119+
);
11081120
}
11091121

11101122
/**
@@ -1115,7 +1127,7 @@ public function getFrontendStatusLabel()
11151127
*/
11161128
public function getStatusLabel()
11171129
{
1118-
return $this->getConfig()->getStatusLabel($this->getStatus());
1130+
return $this->statusLabel->getStatusLabel($this->getStatus());
11191131
}
11201132

11211133
/**

app/code/Magento/Sales/Model/Order/Address/Renderer.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
use Magento\Framework\Event\ManagerInterface as EventManager;
1414
use Magento\Sales\Model\Order\Address;
1515
use Magento\Store\Model\ScopeInterface;
16+
use Magento\Store\Model\StoreManagerInterface;
1617

1718
/**
1819
* Class Renderer used for formatting an order address
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -37,20 +39,26 @@ class Renderer
3739
private $scopeConfig;
3840

3941
/**
40-
* Constructor
41-
*
42+
* @var StoreManagerInterface|null
43+
*/
44+
private $storeManager;
45+
46+
/**
4247
* @param AddressConfig $addressConfig
4348
* @param EventManager $eventManager
4449
* @param ScopeConfigInterface|null $scopeConfig
50+
* @param StoreManagerInterface|null $storeManager
4551
*/
4652
public function __construct(
4753
AddressConfig $addressConfig,
4854
EventManager $eventManager,
49-
?ScopeConfigInterface $scopeConfig = null
55+
?ScopeConfigInterface $scopeConfig = null,
56+
?StoreManagerInterface $storeManager = null
5057
) {
5158
$this->addressConfig = $addressConfig;
5259
$this->eventManager = $eventManager;
5360
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
61+
$this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class);
5462
}
5563

5664
/**
@@ -62,15 +70,15 @@ public function __construct(
6270
*/
6371
public function format(Address $address, $type)
6472
{
65-
$storeId = $address->getOrder()->getStoreId();
66-
$this->addressConfig->setStore($storeId);
73+
$orderStore = $address->getOrder()->getStore();
74+
$this->storeManager->setCurrentStore($orderStore);
6775
$formatType = $this->addressConfig->getFormatByCode($type);
6876
if (!$formatType || !$formatType->getRenderer()) {
6977
return null;
7078
}
7179
$this->eventManager->dispatch('customer_address_format', ['type' => $formatType, 'address' => $address]);
7280
$addressData = $address->getData();
73-
$addressData['locale'] = $this->getLocaleByStoreId((int) $storeId);
81+
$addressData['locale'] = $this->getLocaleByStoreId((int) $orderStore->getId());
7482

7583
return $formatType->getRenderer()->renderArray($addressData);
7684
}

0 commit comments

Comments
 (0)