Skip to content

Commit a5907fd

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into AC-8966
2 parents bb6e291 + 87d2563 commit a5907fd

File tree

132 files changed

+3611
-1479
lines changed

Some content is hidden

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

132 files changed

+3611
-1479
lines changed

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3SyncZeroByteFilesTest.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
<!-- Disable AWS S3 Remote Storage -->
4545
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
4646
</after>
47-
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage"/>
48-
<assertEquals stepKey="assertConfigTest">
49-
<expectedResult type="string">Uploading media files to remote storage.\n- empty.jpg\nEnd of upload.</expectedResult>
47+
<magentoCLI command="remote-storage:sync" timeout="200" stepKey="syncRemoteStorage"/>
48+
<comment userInput="checking remote-storage:sync" stepKey="assertConfigTest"/>
49+
<assertStringContainsString stepKey="checkingRemoteStorageSync">
50+
<expectedResult type="string">Uploading media files to remote storage</expectedResult>
5051
<actualResult type="variable">$syncRemoteStorage</actualResult>
51-
</assertEquals>
52-
52+
</assertStringContainsString>
5353
</test>
5454
</tests>

app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
namespace Magento\BundleGraphQl\Model\Cart\BuyRequest;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Stdlib\ArrayManager;
12+
use Magento\Framework\Stdlib\ArrayManagerFactory;
1113
use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestDataProviderInterface;
1214

1315
/**
@@ -16,17 +18,23 @@
1618
class BundleDataProvider implements BuyRequestDataProviderInterface
1719
{
1820
/**
19-
* @var ArrayManager
21+
* @var ArrayManagerFactory
22+
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
2023
*/
21-
private $arrayManager;
24+
private readonly ArrayManagerFactory $arrayManagerFactory;
2225

2326
/**
24-
* @param ArrayManager $arrayManager
27+
* @param ArrayManager $arrayManager @deprecated @see $arrayManagerFactory
28+
* @param ArrayManagerFactory|null $arrayManagerFactory
29+
*
30+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2531
*/
2632
public function __construct(
27-
ArrayManager $arrayManager
33+
ArrayManager $arrayManager,
34+
?ArrayManagerFactory $arrayManagerFactory = null,
2835
) {
29-
$this->arrayManager = $arrayManager;
36+
$this->arrayManagerFactory = $arrayManagerFactory
37+
?? ObjectManager::getInstance()->get(ArrayManagerFactory::class);
3038
}
3139

3240
/**
@@ -35,7 +43,7 @@ public function __construct(
3543
public function execute(array $cartItemData): array
3644
{
3745
$bundleOptions = [];
38-
$bundleInputs = $this->arrayManager->get('bundle_options', $cartItemData) ?? [];
46+
$bundleInputs = $this->arrayManagerFactory->create()->get('bundle_options', $cartItemData) ?? [];
3947
foreach ($bundleInputs as $bundleInput) {
4048
$bundleOptions['bundle_option'][$bundleInput['id']] = $bundleInput['value'];
4149
$bundleOptions['bundle_option_qty'][$bundleInput['id']] = $bundleInput['quantity'];

app/code/Magento/Catalog/Model/Category/AttributeRepository.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
namespace Magento\Catalog\Model\Category;
77

88
use Magento\Catalog\Api\CategoryAttributeRepositoryInterface;
9+
use Magento\Framework\App\State\ReloadProcessorInterface;
910

10-
class AttributeRepository implements CategoryAttributeRepositoryInterface
11+
class AttributeRepository implements CategoryAttributeRepositoryInterface, ReloadProcessorInterface
1112
{
1213
/**
1314
* @var \Magento\Framework\Api\SearchCriteriaBuilder
@@ -30,7 +31,7 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface
3031
private $eavConfig;
3132

3233
/**
33-
* @var array
34+
* @var array|null
3435
*/
3536
private $metadataCache;
3637

@@ -98,4 +99,14 @@ public function getCustomAttributesMetadata($dataObjectClassName = null)
9899
}
99100
return $this->metadataCache[$dataObjectClassName];
100101
}
102+
103+
/**
104+
* @inheritDoc
105+
*/
106+
public function reloadState(): void
107+
{
108+
$this->filterBuilder->_resetState();
109+
$this->searchCriteriaBuilder->_resetState();
110+
$this->metadataCache = null;
111+
}
101112
}

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Catalog\Model\Product\Type\Simple;
1313
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
1414
use Magento\Framework\Data\OptionSourceInterface;
15+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1516
use Magento\Framework\Pricing\PriceInfo\Factory as PriceInfoFactory;
1617

1718
/**
@@ -21,19 +22,19 @@
2122
* @api
2223
* @since 100.0.2
2324
*/
24-
class Type implements OptionSourceInterface
25+
class Type implements OptionSourceInterface, ResetAfterRequestInterface
2526
{
26-
const TYPE_SIMPLE = 'simple';
27+
public const TYPE_SIMPLE = 'simple';
2728

28-
const TYPE_BUNDLE = 'bundle';
29+
public const TYPE_BUNDLE = 'bundle';
2930

30-
const TYPE_VIRTUAL = 'virtual';
31+
public const TYPE_VIRTUAL = 'virtual';
3132

32-
const DEFAULT_TYPE = 'simple';
33+
public const DEFAULT_TYPE = 'simple';
3334

34-
const DEFAULT_TYPE_MODEL = Simple::class;
35+
public const DEFAULT_TYPE_MODEL = Simple::class;
3536

36-
const DEFAULT_PRICE_MODEL = Price::class;
37+
public const DEFAULT_PRICE_MODEL = Price::class;
3738

3839
/**
3940
* @var ConfigInterface
@@ -55,9 +56,7 @@ class Type implements OptionSourceInterface
5556
protected $_compositeTypes;
5657

5758
/**
58-
* Price models
59-
*
60-
* @var array
59+
* @var array|null|Price
6160
*/
6261
protected $_priceModels;
6362

@@ -107,6 +106,14 @@ public function __construct(
107106
$this->_priceInfoFactory = $priceInfoFactory;
108107
}
109108

109+
/**
110+
* @inheritDoc
111+
*/
112+
public function _resetState(): void
113+
{
114+
$this->_priceModels = null;
115+
}
116+
110117
/**
111118
* Factory to product singleton product type instances
112119
*
@@ -136,7 +143,7 @@ public function factory($product)
136143
* Product type price model factory
137144
*
138145
* @param string $productType
139-
* @return \Magento\Catalog\Model\Product\Type\Price
146+
* @return Price
140147
*/
141148
public function priceFactory($productType)
142149
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,5 +854,9 @@ public function _resetState(): void
854854
{
855855
parent::_resetState();
856856
$this->availableCategoryIdsCache = [];
857+
$this->_type = null;
858+
$this->_entityTable = null;
859+
$this->_entityIdField = null;
860+
$this->linkIdField = null;
857861
}
858862
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright 2023 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Test\Fixture;
18+
19+
use Magento\CatalogInventory\Api\StockRegistryInterface;
20+
use Magento\Framework\DataObject;
21+
use Magento\Framework\DataObjectFactory;
22+
use Magento\TestFramework\Fixture\Api\DataMerger;
23+
use Magento\TestFramework\Fixture\DataFixtureInterface;
24+
25+
class ProductStock implements DataFixtureInterface
26+
{
27+
private const DEFAULT_DATA = [
28+
'prod_id' => null,
29+
'prod_qty' => 1
30+
];
31+
32+
/**
33+
* @var DataObjectFactory
34+
*/
35+
protected DataObjectFactory $dataObjectFactory;
36+
37+
/**
38+
* @var StockRegistryInterface
39+
*/
40+
protected StockRegistryInterface $stockRegistry;
41+
42+
/**
43+
* @var DataMerger
44+
*/
45+
protected DataMerger $dataMerger;
46+
47+
/**
48+
* @param DataObjectFactory $dataObjectFactory
49+
* @param StockRegistryInterface $stockRegistry
50+
* @param DataMerger $dataMerger
51+
*/
52+
public function __construct(
53+
DataObjectFactory $dataObjectFactory,
54+
StockRegistryInterface $stockRegistry,
55+
DataMerger $dataMerger
56+
) {
57+
$this->dataObjectFactory = $dataObjectFactory;
58+
$this->stockRegistry = $stockRegistry;
59+
$this->dataMerger = $dataMerger;
60+
}
61+
62+
/**
63+
* {@inheritdoc}
64+
* @param array $data Parameters. Same format as ProductStock::DEFAULT_DATA
65+
*/
66+
public function apply(array $data = []): ?DataObject
67+
{
68+
$data = $this->dataMerger->merge(self::DEFAULT_DATA, $data);
69+
$stockItem = $this->stockRegistry->getStockItem($data['prod_id']);
70+
$stockItem->setData('is_in_stock', 1);
71+
$stockItem->setData('qty', 90);
72+
$stockItem->setData('manage_stock', 1);
73+
$stockItem->save();
74+
75+
return $this->dataObjectFactory->create(['data' => [$data]]);
76+
}
77+
}

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCategoryNameIsShownInMenuActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<argument name="categoryName" type="string"/>
1717
</arguments>
1818

19+
<waitForElementVisible selector="{{StorefrontHeaderSection.NavigationCategoryByName(categoryName)}}" stepKey="waitForCatName" time="120"/>
1920
<seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(categoryName)}}"
2021
stepKey="seeCatergoryInStoreFront"/>
2122
</actionGroup>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategorySidebarMobileMenuTest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@
4242
<click selector="{{StorefrontHeaderSection.mobileMenuToggle}}" stepKey="openSideMenu"/>
4343
<waitForElementClickable selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createParentCategory.name$$)}}" stepKey="waitForCategoryMenuClickable" />
4444
<click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createParentCategory.name$$)}}" stepKey="expandCategoryMenu"/>
45-
<waitForPageLoad stepKey="waitForSearchResult"/>
45+
<waitForPageLoad stepKey="waitForSearchResult" time="60"/>
4646

4747
<!-- Assert the category expanded successfully -->
4848
<actionGroup ref="StorefrontAssertCategoryNameIsShownInMenuActionGroup" stepKey="verifySubCatMenuItemIsVisibleInTheSidebar">
4949
<argument name="categoryName" value="$$createSubCategory.name$$"/>
5050
</actionGroup>
5151

5252
<!-- Open the subcategory and assert it opened successfully -->
53+
<waitForElementClickable selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createSubCategory.name$$)}}" stepKey="waitForSubCategory" time="90"/>
5354
<click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createSubCategory.name$$)}}" stepKey="openSubCategory"/>
55+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.CategoryTitle}}" stepKey="waitForCategoryName" time="90"/>
5456
<see userInput="$$createSubCategory.name$$" selector="{{StorefrontCategoryMainSection.CategoryTitle}}" stepKey="assertCategoryName"/>
5557
</test>
5658
</tests>

app/code/Magento/Catalog/Test/Unit/Model/Product/Webapi/Rest/RequestTypeBasedDeserializerTest.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@
77
namespace Magento\Catalog\Test\Unit\Model\Product\Webapi\Rest;
88

99
use Magento\Catalog\Model\Product\Webapi\Rest\RequestTypeBasedDeserializer;
10-
use Magento\Framework\Webapi\Rest\Request\DeserializerFactory;
11-
use Magento\Framework\Webapi\Rest\Request;
12-
use PHPUnit\Framework\MockObject\MockObject;
13-
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface;
14-
use Magento\Framework\Webapi\Rest\Request\Deserializer\Json as DeserializerJson;
15-
use Magento\Framework\Webapi\Rest\Request\Deserializer\Xml as DeserializerXml;
1610
use Magento\Framework\App\State;
1711
use Magento\Framework\Json\Decoder;
1812
use Magento\Framework\Serialize\Serializer\Json as SerializerJson;
13+
use Magento\Framework\Webapi\Rest\Request;
14+
use Magento\Framework\Webapi\Rest\Request\Deserializer\Json as DeserializerJson;
15+
use Magento\Framework\Webapi\Rest\Request\Deserializer\Xml as DeserializerXml;
16+
use Magento\Framework\Webapi\Rest\Request\DeserializerFactory;
17+
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface;
1918
use Magento\Framework\Xml\Parser as ParserXml;
19+
use Magento\Framework\Xml\ParserFactory as ParserXmlFactory;
20+
use PHPUnit\Framework\MockObject\MockObject;
2021

22+
/**
23+
* A Test for RequestTypeBasedDeserializer
24+
*
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
*/
2127
class RequestTypeBasedDeserializerTest extends \PHPUnit\Framework\TestCase
2228
{
2329
/** @var RequestTypeBasedDeserializer */
@@ -146,6 +152,8 @@ private function prepareXmlDeserializer(): DeserializerXml
146152
$parserXml = new ParserXml();
147153
/** @var State|MockObject $appStateMock */
148154
$appStateMock = $this->createMock(State::class);
149-
return new DeserializerXml($parserXml, $appStateMock);
155+
$parserXmlFactoryMock = $this->createMock(ParserXmlFactory::class);
156+
$parserXmlFactoryMock->method('create')->willReturn($parserXml);
157+
return new DeserializerXml($parserXml, $appStateMock, $parserXmlFactoryMock);
150158
}
151159
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,4 +1344,11 @@
13441344
</argument>
13451345
</arguments>
13461346
</type>
1347+
<type name="Magento\Framework\App\State\ReloadProcessorComposite">
1348+
<arguments>
1349+
<argument name="processors" xsi:type="array">
1350+
<item name="Magento_Catalog::AttributeRepository" xsi:type="object">Magento\Catalog\Model\Category\AttributeRepository</item>
1351+
</argument>
1352+
</arguments>
1353+
</type>
13471354
</config>

0 commit comments

Comments
 (0)