Skip to content

Commit 826975f

Browse files
authored
Merge branch 'magento-commerce:2.4-develop' into comm_78764_36529
2 parents 0881e58 + 6de2066 commit 826975f

File tree

26 files changed

+776
-36
lines changed

26 files changed

+776
-36
lines changed

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function getPriceList(Product $bundleProduct, $searchMin, $useRegularPric
8484
[(int)$option->getOptionId()],
8585
$bundleProduct
8686
);
87+
$selectionsCollection->setFlag('has_stock_status_filter', true);
8788
$selectionsCollection->removeAttributeToSelect();
88-
$selectionsCollection->addQuantityFilter();
8989

9090
if (!$useRegularPrice) {
9191
$selectionsCollection->addAttributeToSelect('special_price');
@@ -140,6 +140,9 @@ private function isShouldFindMinOption(Product $bundleProduct, $searchMin)
140140
private function addMiniMaxPriceList(Product $bundleProduct, $selectionsCollection, $searchMin, $useRegularPrice)
141141
{
142142
$selectionsCollection->addPriceFilter($bundleProduct, $searchMin, $useRegularPrice);
143+
if ($bundleProduct->isSalable()) {
144+
$selectionsCollection->addQuantityFilter();
145+
}
143146
$selectionsCollection->setPage(0, 1);
144147

145148
$selection = $selectionsCollection->getFirstItem();

app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/DefaultSelectionPriceListProviderTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,47 @@ public function testGetPriceList(): void
177177
$this->selectionCollection->expects($this->once())
178178
->method('getIterator')
179179
->willReturn(new \ArrayIterator([]));
180+
$this->selectionCollection->expects($this->once())
181+
->method('setFlag')
182+
->with('has_stock_status_filter', true);
180183

181184
$this->model->getPriceList($this->product, false, false);
182185
}
186+
187+
public function testGetPriceListWithSearchMin(): void
188+
{
189+
$option = $this->createMock(Option::class);
190+
$option->expects($this->once())->method('getRequired')
191+
->willReturn(true);
192+
$this->optionsCollection->expects($this->any())
193+
->method('getIterator')
194+
->willReturn(new \ArrayIterator([$option]));
195+
$this->typeInstance->expects($this->any())
196+
->method('getOptionsCollection')
197+
->with($this->product)
198+
->willReturn($this->optionsCollection);
199+
$this->product->expects($this->any())
200+
->method('getTypeInstance')
201+
->willReturn($this->typeInstance);
202+
$this->selectionCollection->expects($this->once())
203+
->method('getFirstItem')
204+
->willReturn($this->createMock(Product::class));
205+
$this->typeInstance->expects($this->once())
206+
->method('getSelectionsCollection')
207+
->willReturn($this->selectionCollection);
208+
$this->selectionCollection->expects($this->once())
209+
->method('setFlag')
210+
->with('has_stock_status_filter', true);
211+
$this->selectionCollection->expects($this->once())
212+
->method('addQuantityFilter');
213+
$this->product->expects($this->once())->method('isSalable')->willReturn(true);
214+
$this->optionsCollection->expects($this->once())
215+
->method('getSize')
216+
->willReturn(1);
217+
$this->optionsCollection->expects($this->once())
218+
->method('addFilter')
219+
->willReturn($this->optionsCollection);
220+
221+
$this->model->getPriceList($this->product, true, false);
222+
}
183223
}

app/code/Magento/CatalogGraphQl/Model/Config/FilterAttributeReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private function getFilterType(Attribute $attribute): string
108108
$filterTypeMap = [
109109
'price' => self::FILTER_RANGE_TYPE,
110110
'date' => self::FILTER_RANGE_TYPE,
111+
'datetime' => self::FILTER_RANGE_TYPE,
111112
'select' => self::FILTER_EQUAL_TYPE,
112113
'multiselect' => self::FILTER_EQUAL_TYPE,
113114
'boolean' => self::FILTER_EQUAL_TYPE,
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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\CatalogGraphQl\Test\Unit\Model\Config;
9+
10+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as AttributeCollection;
12+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
13+
use Magento\CatalogGraphQl\Model\Config\FilterAttributeReader;
14+
use Magento\Framework\GraphQl\Schema\Type\Entity\MapperInterface;
15+
use PHPUnit\Framework\MockObject\MockObject;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class FilterAttributeReaderTest extends TestCase
19+
{
20+
/**
21+
* @var MapperInterface|MockObject
22+
*/
23+
private $mapperMock;
24+
25+
/**
26+
* @var CollectionFactory|MockObject
27+
*/
28+
private $collectionFactoryMock;
29+
30+
/**
31+
* @var FilterAttributeReader
32+
*/
33+
private $model;
34+
35+
protected function setUp(): void
36+
{
37+
$this->mapperMock = $this->createMock(MapperInterface::class);
38+
$this->collectionFactoryMock = $this->createMock(AttributeCollectionFactory::class);
39+
$this->model = new FilterAttributeReader($this->mapperMock, $this->collectionFactoryMock);
40+
}
41+
42+
/**
43+
* @dataProvider readDataProvider
44+
* @param string $filterableAttrCode
45+
* @param string $filterableAttrInput
46+
* @param string $searchableAttrCode
47+
* @param string $searchableAttrInput
48+
* @param array $fieldsType
49+
*/
50+
public function testRead(
51+
string $filterableAttrCode,
52+
string $filterableAttrInput,
53+
string $searchableAttrCode,
54+
string $searchableAttrInput,
55+
array $fieldsType
56+
): void {
57+
$this->mapperMock->expects(self::once())
58+
->method('getMappedTypes')
59+
->with('filter_attributes')
60+
->willReturn(['product_filter_attributes' => 'ProductAttributeFilterInput']);
61+
62+
$filterableAttributeCollection = $this->createMock(AttributeCollection::class);
63+
$filterableAttributeCollection->expects(self::once())
64+
->method('addHasOptionsFilter')
65+
->willReturnSelf();
66+
$filterableAttributeCollection->expects(self::once())
67+
->method('addIsFilterableFilter')
68+
->willReturnSelf();
69+
$filterableAttribute = $this->createMock(Attribute::class);
70+
$filterableAttributeCollection->expects(self::once())
71+
->method('getItems')
72+
->willReturn(array_filter([11 => $filterableAttribute]));
73+
$searchableAttributeCollection = $this->createMock(AttributeCollection::class);
74+
$searchableAttributeCollection->expects(self::once())
75+
->method('addHasOptionsFilter')
76+
->willReturnSelf();
77+
$searchableAttributeCollection->expects(self::once())
78+
->method('addIsSearchableFilter')
79+
->willReturnSelf();
80+
$searchableAttributeCollection->expects(self::once())
81+
->method('addDisplayInAdvancedSearchFilter')
82+
->willReturnSelf();
83+
$searchableAttribute = $this->createMock(Attribute::class);
84+
$searchableAttributeCollection->expects(self::once())
85+
->method('getItems')
86+
->willReturn(array_filter([21 => $searchableAttribute]));
87+
$this->collectionFactoryMock->expects(self::exactly(2))
88+
->method('create')
89+
->willReturnOnConsecutiveCalls($filterableAttributeCollection, $searchableAttributeCollection);
90+
91+
$filterableAttribute->method('getAttributeCode')
92+
->willReturn($filterableAttrCode);
93+
$filterableAttribute->method('getFrontendInput')
94+
->willReturn($filterableAttrInput);
95+
$searchableAttribute->method('getAttributeCode')
96+
->willReturn($searchableAttrCode);
97+
$searchableAttribute->method('getFrontendInput')
98+
->willReturn($searchableAttrInput);
99+
100+
$config = $this->model->read();
101+
self::assertNotEmpty($config['ProductAttributeFilterInput']);
102+
self::assertCount(count($fieldsType), $config['ProductAttributeFilterInput']['fields']);
103+
foreach ($fieldsType as $attrCode => $fieldType) {
104+
self::assertEquals($fieldType, $config['ProductAttributeFilterInput']['fields'][$attrCode]['type']);
105+
}
106+
}
107+
108+
public function readDataProvider(): array
109+
{
110+
return [
111+
[
112+
'price',
113+
'price',
114+
'sku',
115+
'text',
116+
[
117+
'price' => 'FilterRangeTypeInput',
118+
'sku' => 'FilterEqualTypeInput',
119+
],
120+
],
121+
[
122+
'date_attr',
123+
'date',
124+
'datetime_attr',
125+
'datetime',
126+
[
127+
'date_attr' => 'FilterRangeTypeInput',
128+
'datetime_attr' => 'FilterRangeTypeInput',
129+
],
130+
],
131+
[
132+
'select_attr',
133+
'select',
134+
'multiselect_attr',
135+
'multiselect',
136+
[
137+
'select_attr' => 'FilterEqualTypeInput',
138+
'multiselect_attr' => 'FilterEqualTypeInput',
139+
],
140+
],
141+
[
142+
'text_attr',
143+
'text',
144+
'textarea_attr',
145+
'textarea',
146+
[
147+
'text_attr' => 'FilterMatchTypeInput',
148+
'textarea_attr' => 'FilterMatchTypeInput',
149+
],
150+
],
151+
[
152+
'boolean_attr',
153+
'boolean',
154+
'boolean_attr',
155+
'boolean',
156+
[
157+
'boolean_attr' => 'FilterEqualTypeInput',
158+
],
159+
],
160+
];
161+
}
162+
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,9 +2080,13 @@ private function getFileContent(string $path): string
20802080
*/
20812081
private function getRemoteFileContent(string $filename): string
20822082
{
2083-
// phpcs:disable Magento2.Functions.DiscouragedFunction
2084-
$content = file_get_contents($filename);
2085-
// phpcs:enable Magento2.Functions.DiscouragedFunction
2083+
try {
2084+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
2085+
$content = file_get_contents($filename);
2086+
} catch (\Exception $e) {
2087+
$content = false;
2088+
}
2089+
20862090
return $content !== false ? $content : '';
20872091
}
20882092

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminOpenPayPalAdvancedFrontendExperienceFeaturesPageActionGroup">
12+
<annotations>
13+
<description>Clicks on 'Configure' for 'PayPal Express Checkout' on the Admin Configuration page.
14+
Expands the 'Advanced Settings' tab.
15+
Expands the 'Frontend Experience Settings' tab.
16+
Expands the 'Features' tab.</description>
17+
</annotations>
18+
<arguments>
19+
<argument name="countryCode" type="string" defaultValue="us"/>
20+
</arguments>
21+
22+
<click selector="{{PayPalExpressCheckoutConfigSection.configureBtn(countryCode)}}" stepKey="clickPayPalConfigureBtn"/>
23+
<click selector="{{PayPalAdvancedSettingConfigSection.advancedSettingTab(countryCode)}}" stepKey="openAdvancedSettingTab"/>
24+
<click selector="{{PayPalAdvancedSettingConfigSection.frontendExperienceSettingsTab(countryCode)}}" stepKey="openFrontendExperienceSettingsTab"/>
25+
<click selector="{{PayPalAdvancedSettingConfigSection.featuresTab(countryCode)}}" stepKey="openFeaturesTab"/>
26+
<seeElement selector="{{PayPalAdvancedFrontendExperienceFeaturesSection.disableFundingOptionsMultiselect(countryCode)}}" stepKey="seeDisableFundingOptionsMultiselect"/>
27+
</actionGroup>
28+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminSelectDisableFundingActionGroup">
12+
<annotations>
13+
<description>Clicks on specified option in 'Disable Funding Options' list.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="countryCode" type="string" defaultValue="us"/>
17+
<argument name="option" type="string" defaultValue="Venmo"/>
18+
</arguments>
19+
20+
<selectOption selector="{{PayPalAdvancedFrontendExperienceFeaturesSection.disableFundingOptionsMultiselect(countryCode)}}" userInput="{{option}}" stepKey="selectOption"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminUnselectDisableFundingActionGroup">
12+
<annotations>
13+
<description>Unselects specified option in 'Disable Funding Options' list.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="countryCode" type="string" defaultValue="us"/>
17+
<argument name="option" type="string" defaultValue="Venmo"/>
18+
</arguments>
19+
20+
<unselectOption selector="{{PayPalAdvancedFrontendExperienceFeaturesSection.disableFundingOptionsMultiselect(countryCode)}}" userInput="{{option}}" stepKey="unselectOption"/>
21+
</actionGroup>
22+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="PayPalAdvancedFrontendExperienceFeaturesSection">
11+
<element name="disableFundingOptionsMultiselect" type="multiselect" selector="#payment_{{countryCode}}_paypal_alternative_payment_methods_express_checkout_{{countryCode}}_settings_ec_settings_ec_advanced_express_checkout_frontend_features_disable_funding_options" parameterized="true"/>
12+
</section>
13+
</sections>

app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection/PayPalAdvancedSettingConfigSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<element name="frontendExperienceSettingsTab" type="button" selector="#payment_{{countryCode}}_paypal_alternative_payment_methods_express_checkout_{{countryCode}}_settings_ec_settings_ec_advanced_express_checkout_frontend-head" parameterized="true"/>
1313
<element name="checkoutPageTab" type="button" selector="#payment_{{countryCode}}_paypal_alternative_payment_methods_express_checkout_{{countryCode}}_settings_ec_settings_ec_advanced_express_checkout_frontend_checkout_page_button-head" parameterized="true"/>
1414
<element name="displayonshoppingcart" type="button" selector="#payment_{{countryCode}}_paypal_alternative_payment_methods_express_checkout_{{countryCode}}_settings_ec_settings_ec_advanced_visible_on_cart" parameterized="true"/>
15+
<element name="featuresTab" type="button" selector="#payment_{{countryCode}}_paypal_alternative_payment_methods_express_checkout_{{countryCode}}_settings_ec_settings_ec_advanced_express_checkout_frontend_features-head" parameterized="true"/>
1516
</section>
1617
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="StorefrontPayPalSmartButtonVenmoSection">
11+
<element name="venmoButton" type="button" selector="//div[@data-funding-source='venmo']"/>
12+
</section>
13+
</sections>

0 commit comments

Comments
 (0)