Skip to content

Commit

Permalink
Merge pull request #8130 from magento-l3/PR_7_JAN_2023
Browse files Browse the repository at this point in the history
L3 Bugfix delivery
  • Loading branch information
admanesachin authored Feb 13, 2023
2 parents d48a739 + 54b5f2f commit 6de2066
Show file tree
Hide file tree
Showing 26 changed files with 776 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public function getPriceList(Product $bundleProduct, $searchMin, $useRegularPric
[(int)$option->getOptionId()],
$bundleProduct
);
$selectionsCollection->setFlag('has_stock_status_filter', true);
$selectionsCollection->removeAttributeToSelect();
$selectionsCollection->addQuantityFilter();

if (!$useRegularPrice) {
$selectionsCollection->addAttributeToSelect('special_price');
Expand Down Expand Up @@ -140,6 +140,9 @@ private function isShouldFindMinOption(Product $bundleProduct, $searchMin)
private function addMiniMaxPriceList(Product $bundleProduct, $selectionsCollection, $searchMin, $useRegularPrice)
{
$selectionsCollection->addPriceFilter($bundleProduct, $searchMin, $useRegularPrice);
if ($bundleProduct->isSalable()) {
$selectionsCollection->addQuantityFilter();
}
$selectionsCollection->setPage(0, 1);

$selection = $selectionsCollection->getFirstItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,47 @@ public function testGetPriceList(): void
$this->selectionCollection->expects($this->once())
->method('getIterator')
->willReturn(new \ArrayIterator([]));
$this->selectionCollection->expects($this->once())
->method('setFlag')
->with('has_stock_status_filter', true);

$this->model->getPriceList($this->product, false, false);
}

public function testGetPriceListWithSearchMin(): void
{
$option = $this->createMock(Option::class);
$option->expects($this->once())->method('getRequired')
->willReturn(true);
$this->optionsCollection->expects($this->any())
->method('getIterator')
->willReturn(new \ArrayIterator([$option]));
$this->typeInstance->expects($this->any())
->method('getOptionsCollection')
->with($this->product)
->willReturn($this->optionsCollection);
$this->product->expects($this->any())
->method('getTypeInstance')
->willReturn($this->typeInstance);
$this->selectionCollection->expects($this->once())
->method('getFirstItem')
->willReturn($this->createMock(Product::class));
$this->typeInstance->expects($this->once())
->method('getSelectionsCollection')
->willReturn($this->selectionCollection);
$this->selectionCollection->expects($this->once())
->method('setFlag')
->with('has_stock_status_filter', true);
$this->selectionCollection->expects($this->once())
->method('addQuantityFilter');
$this->product->expects($this->once())->method('isSalable')->willReturn(true);
$this->optionsCollection->expects($this->once())
->method('getSize')
->willReturn(1);
$this->optionsCollection->expects($this->once())
->method('addFilter')
->willReturn($this->optionsCollection);

$this->model->getPriceList($this->product, true, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private function getFilterType(Attribute $attribute): string
$filterTypeMap = [
'price' => self::FILTER_RANGE_TYPE,
'date' => self::FILTER_RANGE_TYPE,
'datetime' => self::FILTER_RANGE_TYPE,
'select' => self::FILTER_EQUAL_TYPE,
'multiselect' => self::FILTER_EQUAL_TYPE,
'boolean' => self::FILTER_EQUAL_TYPE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CatalogGraphQl\Test\Unit\Model\Config;

use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as AttributeCollection;
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
use Magento\CatalogGraphQl\Model\Config\FilterAttributeReader;
use Magento\Framework\GraphQl\Schema\Type\Entity\MapperInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class FilterAttributeReaderTest extends TestCase
{
/**
* @var MapperInterface|MockObject
*/
private $mapperMock;

/**
* @var CollectionFactory|MockObject
*/
private $collectionFactoryMock;

/**
* @var FilterAttributeReader
*/
private $model;

protected function setUp(): void
{
$this->mapperMock = $this->createMock(MapperInterface::class);
$this->collectionFactoryMock = $this->createMock(AttributeCollectionFactory::class);
$this->model = new FilterAttributeReader($this->mapperMock, $this->collectionFactoryMock);
}

/**
* @dataProvider readDataProvider
* @param string $filterableAttrCode
* @param string $filterableAttrInput
* @param string $searchableAttrCode
* @param string $searchableAttrInput
* @param array $fieldsType
*/
public function testRead(
string $filterableAttrCode,
string $filterableAttrInput,
string $searchableAttrCode,
string $searchableAttrInput,
array $fieldsType
): void {
$this->mapperMock->expects(self::once())
->method('getMappedTypes')
->with('filter_attributes')
->willReturn(['product_filter_attributes' => 'ProductAttributeFilterInput']);

$filterableAttributeCollection = $this->createMock(AttributeCollection::class);
$filterableAttributeCollection->expects(self::once())
->method('addHasOptionsFilter')
->willReturnSelf();
$filterableAttributeCollection->expects(self::once())
->method('addIsFilterableFilter')
->willReturnSelf();
$filterableAttribute = $this->createMock(Attribute::class);
$filterableAttributeCollection->expects(self::once())
->method('getItems')
->willReturn(array_filter([11 => $filterableAttribute]));
$searchableAttributeCollection = $this->createMock(AttributeCollection::class);
$searchableAttributeCollection->expects(self::once())
->method('addHasOptionsFilter')
->willReturnSelf();
$searchableAttributeCollection->expects(self::once())
->method('addIsSearchableFilter')
->willReturnSelf();
$searchableAttributeCollection->expects(self::once())
->method('addDisplayInAdvancedSearchFilter')
->willReturnSelf();
$searchableAttribute = $this->createMock(Attribute::class);
$searchableAttributeCollection->expects(self::once())
->method('getItems')
->willReturn(array_filter([21 => $searchableAttribute]));
$this->collectionFactoryMock->expects(self::exactly(2))
->method('create')
->willReturnOnConsecutiveCalls($filterableAttributeCollection, $searchableAttributeCollection);

$filterableAttribute->method('getAttributeCode')
->willReturn($filterableAttrCode);
$filterableAttribute->method('getFrontendInput')
->willReturn($filterableAttrInput);
$searchableAttribute->method('getAttributeCode')
->willReturn($searchableAttrCode);
$searchableAttribute->method('getFrontendInput')
->willReturn($searchableAttrInput);

$config = $this->model->read();
self::assertNotEmpty($config['ProductAttributeFilterInput']);
self::assertCount(count($fieldsType), $config['ProductAttributeFilterInput']['fields']);
foreach ($fieldsType as $attrCode => $fieldType) {
self::assertEquals($fieldType, $config['ProductAttributeFilterInput']['fields'][$attrCode]['type']);
}
}

public function readDataProvider(): array
{
return [
[
'price',
'price',
'sku',
'text',
[
'price' => 'FilterRangeTypeInput',
'sku' => 'FilterEqualTypeInput',
],
],
[
'date_attr',
'date',
'datetime_attr',
'datetime',
[
'date_attr' => 'FilterRangeTypeInput',
'datetime_attr' => 'FilterRangeTypeInput',
],
],
[
'select_attr',
'select',
'multiselect_attr',
'multiselect',
[
'select_attr' => 'FilterEqualTypeInput',
'multiselect_attr' => 'FilterEqualTypeInput',
],
],
[
'text_attr',
'text',
'textarea_attr',
'textarea',
[
'text_attr' => 'FilterMatchTypeInput',
'textarea_attr' => 'FilterMatchTypeInput',
],
],
[
'boolean_attr',
'boolean',
'boolean_attr',
'boolean',
[
'boolean_attr' => 'FilterEqualTypeInput',
],
],
];
}
}
10 changes: 7 additions & 3 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -2080,9 +2080,13 @@ private function getFileContent(string $path): string
*/
private function getRemoteFileContent(string $filename): string
{
// phpcs:disable Magento2.Functions.DiscouragedFunction
$content = file_get_contents($filename);
// phpcs:enable Magento2.Functions.DiscouragedFunction
try {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$content = file_get_contents($filename);
} catch (\Exception $e) {
$content = false;
}

return $content !== false ? $content : '';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminOpenPayPalAdvancedFrontendExperienceFeaturesPageActionGroup">
<annotations>
<description>Clicks on 'Configure' for 'PayPal Express Checkout' on the Admin Configuration page.
Expands the 'Advanced Settings' tab.
Expands the 'Frontend Experience Settings' tab.
Expands the 'Features' tab.</description>
</annotations>
<arguments>
<argument name="countryCode" type="string" defaultValue="us"/>
</arguments>

<click selector="{{PayPalExpressCheckoutConfigSection.configureBtn(countryCode)}}" stepKey="clickPayPalConfigureBtn"/>
<click selector="{{PayPalAdvancedSettingConfigSection.advancedSettingTab(countryCode)}}" stepKey="openAdvancedSettingTab"/>
<click selector="{{PayPalAdvancedSettingConfigSection.frontendExperienceSettingsTab(countryCode)}}" stepKey="openFrontendExperienceSettingsTab"/>
<click selector="{{PayPalAdvancedSettingConfigSection.featuresTab(countryCode)}}" stepKey="openFeaturesTab"/>
<seeElement selector="{{PayPalAdvancedFrontendExperienceFeaturesSection.disableFundingOptionsMultiselect(countryCode)}}" stepKey="seeDisableFundingOptionsMultiselect"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminSelectDisableFundingActionGroup">
<annotations>
<description>Clicks on specified option in 'Disable Funding Options' list.</description>
</annotations>
<arguments>
<argument name="countryCode" type="string" defaultValue="us"/>
<argument name="option" type="string" defaultValue="Venmo"/>
</arguments>

<selectOption selector="{{PayPalAdvancedFrontendExperienceFeaturesSection.disableFundingOptionsMultiselect(countryCode)}}" userInput="{{option}}" stepKey="selectOption"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminUnselectDisableFundingActionGroup">
<annotations>
<description>Unselects specified option in 'Disable Funding Options' list.</description>
</annotations>
<arguments>
<argument name="countryCode" type="string" defaultValue="us"/>
<argument name="option" type="string" defaultValue="Venmo"/>
</arguments>

<unselectOption selector="{{PayPalAdvancedFrontendExperienceFeaturesSection.disableFundingOptionsMultiselect(countryCode)}}" userInput="{{option}}" stepKey="unselectOption"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="PayPalAdvancedFrontendExperienceFeaturesSection">
<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"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<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"/>
<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"/>
<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"/>
<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"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontPayPalSmartButtonVenmoSection">
<element name="venmoButton" type="button" selector="//div[@data-funding-source='venmo']"/>
</section>
</sections>
Loading

0 comments on commit 6de2066

Please sign in to comment.