Skip to content

Commit

Permalink
Merge pull request #6633 from magento-tsg/2.4-develop-pr126
Browse files Browse the repository at this point in the history
[Arrows] Fixes for 2.4 (pr126) (2.4-develop)
  • Loading branch information
zakdma committed Feb 18, 2021
2 parents 4b0ef30 + 519e018 commit 840b5f8
Show file tree
Hide file tree
Showing 25 changed files with 954 additions and 525 deletions.
67 changes: 39 additions & 28 deletions app/code/Magento/Catalog/Model/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Model;

use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager as CategoryLayoutManager;
use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager as ProductLayoutManager;
use Magento\Framework\App\ObjectManager;
use \Magento\Framework\TranslateInterface;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\DataObject;
use Magento\Framework\Model\Context;
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TranslateInterface;
use Magento\Framework\View\DesignInterface;

/**
* Catalog Custom Category design Model
Expand All @@ -28,12 +36,12 @@ class Design extends \Magento\Framework\Model\AbstractModel
/**
* Design package instance
*
* @var \Magento\Framework\View\DesignInterface
* @var DesignInterface
*/
protected $_design = null;

/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
* @var TimezoneInterface
*/
protected $_localeDate;

Expand All @@ -53,25 +61,25 @@ class Design extends \Magento\Framework\Model\AbstractModel
private $productLayoutUpdates;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Framework\View\DesignInterface $design
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param Context $context
* @param Registry $registry
* @param TimezoneInterface $localeDate
* @param DesignInterface $design
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
* @param TranslateInterface|null $translator
* @param CategoryLayoutManager|null $categoryLayoutManager
* @param ProductLayoutManager|null $productLayoutManager
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
Context $context,
Registry $registry,
TimezoneInterface $localeDate,
DesignInterface $design,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = [],
TranslateInterface $translator = null,
?CategoryLayoutManager $categoryLayoutManager = null,
Expand Down Expand Up @@ -104,7 +112,7 @@ public function applyCustomDesign($design)
* Get custom layout settings
*
* @param Category|Product $object
* @return \Magento\Framework\DataObject
* @return DataObject
*/
public function getDesignSettings($object)
{
Expand Down Expand Up @@ -134,14 +142,17 @@ public function getDesignSettings($object)
* Extract custom layout settings from category or product object
*
* @param Category|Product $object
* @return \Magento\Framework\DataObject
* @return DataObject
*/
protected function _extractSettings($object)
{
$settings = new \Magento\Framework\DataObject();
$settings = new DataObject();
if (!$object) {
return $settings;
}
$settings->setPageLayout($object->getPageLayout());
$settings->setLayoutUpdates((array)$object->getCustomLayoutUpdate());

$date = $object->getCustomDesignDate();
if (array_key_exists(
'from',
Expand All @@ -155,28 +166,28 @@ protected function _extractSettings($object)
$date['to']
)
) {
$settings->setCustomDesign(
$object->getCustomDesign()
)->setPageLayout(
$object->getPageLayout()
)->setLayoutUpdates(
(array)$object->getCustomLayoutUpdate()
);
if ($object->getCustomDesign()) {
$settings->setCustomDesign($object->getCustomDesign());
}
if ($object->getCustomLayout()) {
$settings->setPageLayout($object->getCustomLayout());
}
if ($object instanceof Category) {
$this->categoryLayoutUpdates->extractCustomSettings($object, $settings);
} elseif ($object instanceof Product) {
$this->productLayoutUpdates->extractCustomSettings($object, $settings);
}
}

return $settings;
}

/**
* Merge custom design settings
*
* @param \Magento\Framework\DataObject $categorySettings
* @param \Magento\Framework\DataObject $productSettings
* @return \Magento\Framework\DataObject
* @param DataObject $categorySettings
* @param DataObject $productSettings
* @return DataObject
*/
protected function _mergeSettings($categorySettings, $productSettings)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="AssertStorefrontProductDropDownOptionValueActionGroup">
<annotations>
<description>Validates that the provided Product Option is selected under the provided Drop-down Attribute.</description>
</annotations>
<arguments>
<argument name="attributeLabel" type="string" defaultValue="{{ProductAttributeFrontendLabel.label}}"/>
<argument name="optionLabel" type="string" defaultValue="{{productAttributeOption1.label}}"/>
</arguments>

<waitForElementVisible selector="{{StorefrontProductInfoMainSection.attributeSelectByAttributeID(attributeLabel)}}" stepKey="waitForAttributeVisible" />
<seeOptionIsSelected selector="{{StorefrontProductInfoMainSection.attributeSelectByAttributeID(attributeLabel)}}" userInput="{{optionLabel}}" stepKey="assertAttributeOption"/>
</actionGroup>
</actionGroups>
6 changes: 5 additions & 1 deletion app/code/Magento/Downloadable/Model/Sample/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Magento\Framework\EntityManager\Operation\ExtensionInterface;

/**
* Class DeleteHandler
* Delete Handler for Downloadable Product Samples.
*/
class DeleteHandler implements ExtensionInterface
{
Expand All @@ -27,6 +27,8 @@ public function __construct(SampleRepository $sampleRepository)
}

/**
* Delete Downloadable Samples for the provided Entity.
*
* @param object $entity
* @param array $arguments
* @return \Magento\Catalog\Api\Data\ProductInterface|object
Expand All @@ -42,6 +44,8 @@ public function execute($entity, $arguments = [])
foreach ($this->sampleRepository->getList($entity->getSku()) as $sample) {
$this->sampleRepository->delete($sample->getId());
}
$entity->setDownloadableSamples(null);

return $entity;
}
}
9 changes: 5 additions & 4 deletions app/code/Magento/Downloadable/Model/Sample/ReadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Magento\Framework\EntityManager\Operation\ExtensionInterface;

/**
* Class ReadHandler
* Read Handler for Downloadable Product Samples.
*/
class ReadHandler implements ExtensionInterface
{
Expand All @@ -27,6 +27,8 @@ public function __construct(SampleRepository $sampleRepository)
}

/**
* Read Downloadable Samples for the provided Entity.
*
* @param object $entity
* @param array $arguments
* @return \Magento\Catalog\Api\Data\ProductInterface|object
Expand All @@ -40,10 +42,9 @@ public function execute($entity, $arguments = [])
}
$entityExtension = $entity->getExtensionAttributes();
$samples = $this->sampleRepository->getSamplesByProduct($entity);
if ($samples) {
$entityExtension->setDownloadableProductSamples($samples);
}
$entityExtension->setDownloadableProductSamples($samples);
$entity->setExtensionAttributes($entityExtension);

return $entity;
}
}
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="AssertStorefrontNoSampleOnDownloadableProductPageActionGroup">
<annotations>
<description>Validates that the provided Sample Title is NOT present on Downloadable Product details page.</description>
</annotations>
<arguments>
<argument name="sampleTitle" type="string" defaultValue="{{downloadableSampleUrl.title}}"/>
</arguments>

<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableSamplesListSection}}" stepKey="waitForDownloadableSamplesList"/>
<dontSeeElement selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(sampleTitle)}}" stepKey="dontSeeDownloadableSample"/>
</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="AssertStorefrontSampleOnDownloadableProductPageActionGroup">
<annotations>
<description>Validates that the provided Sample Title is present on Downloadable Product details page.</description>
</annotations>
<arguments>
<argument name="sampleTitle" type="string" defaultValue="{{downloadableSampleUrl.title}}"/>
</arguments>

<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableSamplesListSection}}" stepKey="waitForDownloadableSamplesList"/>
<seeElement selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(sampleTitle)}}" stepKey="seeDownloadableSample"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
<element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" />
<element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" />
<element name="downloadableLinksListSection" type="text" selector="#downloadable-links-list" timeout="30"/>
<element name="downloadableSamplesListSection" type="text" selector=".items.samples" timeout="30"/>
</section>
</sections>
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="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup">
<annotations>
<description>Checks the provided payment method radio button presents on the Admin Create Order page.</description>
</annotations>
<arguments>
<argument name="paymentMethodName" type="string" defaultValue="Check / Money order"/>
</arguments>

<conditionalClick selector="{{AdminOrderFormPaymentSection.linkPaymentOptions}}" dependentSelector="{{AdminOrderFormPaymentSection.linkPaymentOptions}}" visible="true" stepKey="clickGetAvailablePaymentMethods"/>
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}" stepKey="waitForPaymentOptions"/>
<seeElement selector="{{AdminOrderFormPaymentSection.paymentLabelWithRadioButton(paymentMethodName)}}" stepKey="seeLabelWithRadioButton"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<element name="purchaseOrderOption" type="radio" selector="#p_method_purchaseorder" timeout="30"/>
<element name="purchaseOrderNumber" type="input" selector="#po_number"/>
<element name="freePaymentLabel" type="text" selector="#order-billing_method_form label[for='p_method_free']"/>
<element name="paymentLabelWithRadioButton" type="text" selector="#order-billing_method_form .admin__field-option input[title='{{paymentMethodName}}'] + label" parameterized="true"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCheckingPaymentMethodRadioButtonPresentAfterReloadOrderPageTest">
<annotations>
<features value="Sales"/>
<stories value="Create order in Admin"/>
<title value="Checking payment method radio button is presented after reloading the order page"/>
<description value="Checking payment method radio button is presented after reloading the order page"/>
<severity value="AVERAGE"/>
<testCaseId value="MC-40878"/>
<useCaseId value="MC-40013"/>
<group value="sales"/>
</annotations>
<before>
<!-- Enable Check/Money order payment method -->
<magentoCLI command="config:set {{EnablePaymentCheckMOConfigData.path}} {{EnablePaymentCheckMOConfigData.value}}" stepKey="enableCheckMoneyOrderPayment"/>
<!-- Enable Bank Transfer Payment method -->
<magentoCLI command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}" stepKey="enableBankTransferPayment"/>
<!-- Create simple product -->
<createData entity="SimpleProduct2" stepKey="createProduct"/>
<!-- Create customer -->
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
<!-- Login to Admin page -->
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<!-- Disable Bank Transfer Payment method -->
<magentoCLI command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}" stepKey="disableBankTransferPayment"/>
<!-- Delete entities -->
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
<!-- Logout from Admin page -->
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
</after>

<!-- Create new order -->
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="navigateToNewOrderWithExistingCustomer">
<argument name="customer" value="$createCustomer$"/>
</actionGroup>

<!-- Add Simple product to order -->
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addSimpleProductToTheOrder">
<argument name="product" value="$createProduct$"/>
</actionGroup>

<!-- Assert label with radio button presents on the page -->
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertCheckMORadioButtonIsPresent"/>
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertBankTransferRadioButtonIsPresent">
<argument name="paymentMethodName" value="Bank Transfer Payment"/>
</actionGroup>

<actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/>

<!-- Assert label with radio button presents after reload the page -->
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertCheckMORadioButtonIsPresentAfterReload"/>
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertBankTransferRadioButtonIsPresentAfterReload">
<argument name="paymentMethodName" value="Bank Transfer Payment"/>
</actionGroup>
</test>
</tests>
Loading

0 comments on commit 840b5f8

Please sign in to comment.