Skip to content

Commit 840b5f8

Browse files
authored
Merge pull request #6633 from magento-tsg/2.4-develop-pr126
[Arrows] Fixes for 2.4 (pr126) (2.4-develop)
2 parents 4b0ef30 + 519e018 commit 840b5f8

25 files changed

+954
-525
lines changed

app/code/Magento/Catalog/Model/Design.php

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Catalog\Model;
78

89
use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager as CategoryLayoutManager;
910
use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager as ProductLayoutManager;
1011
use Magento\Framework\App\ObjectManager;
11-
use \Magento\Framework\TranslateInterface;
12+
use Magento\Framework\Data\Collection\AbstractDb;
13+
use Magento\Framework\DataObject;
14+
use Magento\Framework\Model\Context;
15+
use Magento\Framework\Model\ResourceModel\AbstractResource;
16+
use Magento\Framework\Registry;
17+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
18+
use Magento\Framework\TranslateInterface;
19+
use Magento\Framework\View\DesignInterface;
1220

1321
/**
1422
* Catalog Custom Category design Model
@@ -28,12 +36,12 @@ class Design extends \Magento\Framework\Model\AbstractModel
2836
/**
2937
* Design package instance
3038
*
31-
* @var \Magento\Framework\View\DesignInterface
39+
* @var DesignInterface
3240
*/
3341
protected $_design = null;
3442

3543
/**
36-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
44+
* @var TimezoneInterface
3745
*/
3846
protected $_localeDate;
3947

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

5563
/**
56-
* @param \Magento\Framework\Model\Context $context
57-
* @param \Magento\Framework\Registry $registry
58-
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
59-
* @param \Magento\Framework\View\DesignInterface $design
60-
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
61-
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
64+
* @param Context $context
65+
* @param Registry $registry
66+
* @param TimezoneInterface $localeDate
67+
* @param DesignInterface $design
68+
* @param AbstractResource|null $resource
69+
* @param AbstractDb|null $resourceCollection
6270
* @param array $data
6371
* @param TranslateInterface|null $translator
6472
* @param CategoryLayoutManager|null $categoryLayoutManager
6573
* @param ProductLayoutManager|null $productLayoutManager
6674
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6775
*/
6876
public function __construct(
69-
\Magento\Framework\Model\Context $context,
70-
\Magento\Framework\Registry $registry,
71-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
72-
\Magento\Framework\View\DesignInterface $design,
73-
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
74-
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
77+
Context $context,
78+
Registry $registry,
79+
TimezoneInterface $localeDate,
80+
DesignInterface $design,
81+
AbstractResource $resource = null,
82+
AbstractDb $resourceCollection = null,
7583
array $data = [],
7684
TranslateInterface $translator = null,
7785
?CategoryLayoutManager $categoryLayoutManager = null,
@@ -104,7 +112,7 @@ public function applyCustomDesign($design)
104112
* Get custom layout settings
105113
*
106114
* @param Category|Product $object
107-
* @return \Magento\Framework\DataObject
115+
* @return DataObject
108116
*/
109117
public function getDesignSettings($object)
110118
{
@@ -134,14 +142,17 @@ public function getDesignSettings($object)
134142
* Extract custom layout settings from category or product object
135143
*
136144
* @param Category|Product $object
137-
* @return \Magento\Framework\DataObject
145+
* @return DataObject
138146
*/
139147
protected function _extractSettings($object)
140148
{
141-
$settings = new \Magento\Framework\DataObject();
149+
$settings = new DataObject();
142150
if (!$object) {
143151
return $settings;
144152
}
153+
$settings->setPageLayout($object->getPageLayout());
154+
$settings->setLayoutUpdates((array)$object->getCustomLayoutUpdate());
155+
145156
$date = $object->getCustomDesignDate();
146157
if (array_key_exists(
147158
'from',
@@ -155,28 +166,28 @@ protected function _extractSettings($object)
155166
$date['to']
156167
)
157168
) {
158-
$settings->setCustomDesign(
159-
$object->getCustomDesign()
160-
)->setPageLayout(
161-
$object->getPageLayout()
162-
)->setLayoutUpdates(
163-
(array)$object->getCustomLayoutUpdate()
164-
);
169+
if ($object->getCustomDesign()) {
170+
$settings->setCustomDesign($object->getCustomDesign());
171+
}
172+
if ($object->getCustomLayout()) {
173+
$settings->setPageLayout($object->getCustomLayout());
174+
}
165175
if ($object instanceof Category) {
166176
$this->categoryLayoutUpdates->extractCustomSettings($object, $settings);
167177
} elseif ($object instanceof Product) {
168178
$this->productLayoutUpdates->extractCustomSettings($object, $settings);
169179
}
170180
}
181+
171182
return $settings;
172183
}
173184

174185
/**
175186
* Merge custom design settings
176187
*
177-
* @param \Magento\Framework\DataObject $categorySettings
178-
* @param \Magento\Framework\DataObject $productSettings
179-
* @return \Magento\Framework\DataObject
188+
* @param DataObject $categorySettings
189+
* @param DataObject $productSettings
190+
* @return DataObject
180191
*/
181192
protected function _mergeSettings($categorySettings, $productSettings)
182193
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="AssertStorefrontProductDropDownOptionValueActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Product Option is selected under the provided Drop-down Attribute.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="attributeLabel" type="string" defaultValue="{{ProductAttributeFrontendLabel.label}}"/>
17+
<argument name="optionLabel" type="string" defaultValue="{{productAttributeOption1.label}}"/>
18+
</arguments>
19+
20+
<waitForElementVisible selector="{{StorefrontProductInfoMainSection.attributeSelectByAttributeID(attributeLabel)}}" stepKey="waitForAttributeVisible" />
21+
<seeOptionIsSelected selector="{{StorefrontProductInfoMainSection.attributeSelectByAttributeID(attributeLabel)}}" userInput="{{optionLabel}}" stepKey="assertAttributeOption"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/Downloadable/Model/Sample/DeleteHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1010

1111
/**
12-
* Class DeleteHandler
12+
* Delete Handler for Downloadable Product Samples.
1313
*/
1414
class DeleteHandler implements ExtensionInterface
1515
{
@@ -27,6 +27,8 @@ public function __construct(SampleRepository $sampleRepository)
2727
}
2828

2929
/**
30+
* Delete Downloadable Samples for the provided Entity.
31+
*
3032
* @param object $entity
3133
* @param array $arguments
3234
* @return \Magento\Catalog\Api\Data\ProductInterface|object
@@ -42,6 +44,8 @@ public function execute($entity, $arguments = [])
4244
foreach ($this->sampleRepository->getList($entity->getSku()) as $sample) {
4345
$this->sampleRepository->delete($sample->getId());
4446
}
47+
$entity->setDownloadableSamples(null);
48+
4549
return $entity;
4650
}
4751
}

app/code/Magento/Downloadable/Model/Sample/ReadHandler.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1010

1111
/**
12-
* Class ReadHandler
12+
* Read Handler for Downloadable Product Samples.
1313
*/
1414
class ReadHandler implements ExtensionInterface
1515
{
@@ -27,6 +27,8 @@ public function __construct(SampleRepository $sampleRepository)
2727
}
2828

2929
/**
30+
* Read Downloadable Samples for the provided Entity.
31+
*
3032
* @param object $entity
3133
* @param array $arguments
3234
* @return \Magento\Catalog\Api\Data\ProductInterface|object
@@ -40,10 +42,9 @@ public function execute($entity, $arguments = [])
4042
}
4143
$entityExtension = $entity->getExtensionAttributes();
4244
$samples = $this->sampleRepository->getSamplesByProduct($entity);
43-
if ($samples) {
44-
$entityExtension->setDownloadableProductSamples($samples);
45-
}
45+
$entityExtension->setDownloadableProductSamples($samples);
4646
$entity->setExtensionAttributes($entityExtension);
47+
4748
return $entity;
4849
}
4950
}
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="AssertStorefrontNoSampleOnDownloadableProductPageActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Sample Title is NOT present on Downloadable Product details page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="sampleTitle" type="string" defaultValue="{{downloadableSampleUrl.title}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableSamplesListSection}}" stepKey="waitForDownloadableSamplesList"/>
20+
<dontSeeElement selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(sampleTitle)}}" stepKey="dontSeeDownloadableSample"/>
21+
</actionGroup>
22+
</actionGroups>
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="AssertStorefrontSampleOnDownloadableProductPageActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Sample Title is present on Downloadable Product details page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="sampleTitle" type="string" defaultValue="{{downloadableSampleUrl.title}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableSamplesListSection}}" stepKey="waitForDownloadableSamplesList"/>
20+
<seeElement selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(sampleTitle)}}" stepKey="seeDownloadableSample"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" />
1818
<element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" />
1919
<element name="downloadableLinksListSection" type="text" selector="#downloadable-links-list" timeout="30"/>
20+
<element name="downloadableSamplesListSection" type="text" selector=".items.samples" timeout="30"/>
2021
</section>
2122
</sections>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup">
11+
<annotations>
12+
<description>Checks the provided payment method radio button presents on the Admin Create Order page.</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="paymentMethodName" type="string" defaultValue="Check / Money order"/>
16+
</arguments>
17+
18+
<conditionalClick selector="{{AdminOrderFormPaymentSection.linkPaymentOptions}}" dependentSelector="{{AdminOrderFormPaymentSection.linkPaymentOptions}}" visible="true" stepKey="clickGetAvailablePaymentMethods"/>
19+
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}" stepKey="waitForPaymentOptions"/>
20+
<seeElement selector="{{AdminOrderFormPaymentSection.paymentLabelWithRadioButton(paymentMethodName)}}" stepKey="seeLabelWithRadioButton"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormPaymentSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
<element name="purchaseOrderOption" type="radio" selector="#p_method_purchaseorder" timeout="30"/>
3030
<element name="purchaseOrderNumber" type="input" selector="#po_number"/>
3131
<element name="freePaymentLabel" type="text" selector="#order-billing_method_form label[for='p_method_free']"/>
32+
<element name="paymentLabelWithRadioButton" type="text" selector="#order-billing_method_form .admin__field-option input[title='{{paymentMethodName}}'] + label" parameterized="true"/>
3233
</section>
3334
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCheckingPaymentMethodRadioButtonPresentAfterReloadOrderPageTest">
11+
<annotations>
12+
<features value="Sales"/>
13+
<stories value="Create order in Admin"/>
14+
<title value="Checking payment method radio button is presented after reloading the order page"/>
15+
<description value="Checking payment method radio button is presented after reloading the order page"/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="MC-40878"/>
18+
<useCaseId value="MC-40013"/>
19+
<group value="sales"/>
20+
</annotations>
21+
<before>
22+
<!-- Enable Check/Money order payment method -->
23+
<magentoCLI command="config:set {{EnablePaymentCheckMOConfigData.path}} {{EnablePaymentCheckMOConfigData.value}}" stepKey="enableCheckMoneyOrderPayment"/>
24+
<!-- Enable Bank Transfer Payment method -->
25+
<magentoCLI command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}" stepKey="enableBankTransferPayment"/>
26+
<!-- Create simple product -->
27+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
28+
<!-- Create customer -->
29+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
30+
<!-- Login to Admin page -->
31+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
32+
</before>
33+
<after>
34+
<!-- Disable Bank Transfer Payment method -->
35+
<magentoCLI command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}" stepKey="disableBankTransferPayment"/>
36+
<!-- Delete entities -->
37+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
38+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
39+
<!-- Logout from Admin page -->
40+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
41+
</after>
42+
43+
<!-- Create new order -->
44+
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="navigateToNewOrderWithExistingCustomer">
45+
<argument name="customer" value="$createCustomer$"/>
46+
</actionGroup>
47+
48+
<!-- Add Simple product to order -->
49+
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addSimpleProductToTheOrder">
50+
<argument name="product" value="$createProduct$"/>
51+
</actionGroup>
52+
53+
<!-- Assert label with radio button presents on the page -->
54+
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertCheckMORadioButtonIsPresent"/>
55+
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertBankTransferRadioButtonIsPresent">
56+
<argument name="paymentMethodName" value="Bank Transfer Payment"/>
57+
</actionGroup>
58+
59+
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/>
60+
61+
<!-- Assert label with radio button presents after reload the page -->
62+
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertCheckMORadioButtonIsPresentAfterReload"/>
63+
<actionGroup ref="AssertAdminPaymentMethodRadioButtonExistsOnCreateOrderPageActionGroup" stepKey="assertBankTransferRadioButtonIsPresentAfterReload">
64+
<argument name="paymentMethodName" value="Bank Transfer Payment"/>
65+
</actionGroup>
66+
</test>
67+
</tests>

0 commit comments

Comments
 (0)