Skip to content

Commit 2c173c9

Browse files
authored
Merge pull request #6475 from magento-tsg/2.4-develop-pr115
[Arrows] Fixes for 2.4 (pr115) (2.4-develop)
2 parents b55e1f2 + 7c07984 commit 2c173c9

15 files changed

+208
-17
lines changed

app/code/Magento/Backend/App/Area/FrontNameResolver.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ public function isHostBackend()
123123
if ($this->scopeConfig->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE)) {
124124
$backendUrl = $this->scopeConfig->getValue(self::XML_PATH_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE);
125125
} else {
126-
$backendUrl = $this->scopeConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
126+
$backendUrl = $this->config->getValue(Store::XML_PATH_UNSECURE_BASE_URL);
127+
if ($backendUrl === null) {
128+
$backendUrl = $this->scopeConfig->getValue(
129+
Store::XML_PATH_UNSECURE_BASE_URL,
130+
ScopeInterface::SCOPE_STORE
131+
);
132+
}
127133
}
128134
$host = $this->request->getServer('HTTP_HOST', '');
129135
return stripos($this->getHostWithPort($backendUrl), (string) $host) !== false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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="AdminDeleteAllProductAttributesFilteredByCodeActionGroup">
11+
<annotations>
12+
<description>Open product attributes grid filter it by attribute code and delete all found attributes one by one.</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="codeFilter" type="string" defaultValue="fake-code"/>
16+
</arguments>
17+
18+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
19+
<!-- It sometimes is loading too long for default 10s -->
20+
<waitForPageLoad time="60" stepKey="waitForPageFullyLoaded"/>
21+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="clearExistingFilters"/>
22+
<fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}" userInput="{{codeFilter}}" stepKey="fillAttributeCodeFilterField"/>
23+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="applyGridFilter"/>
24+
<helper class="\Magento\Catalog\Test\Mftf\Helper\CatalogHelper" method="deleteAllProductAttributesOneByOne" stepKey="deleteAllProductAttributesOneByOne">
25+
<argument name="notEmptyRow">{{AdminDataGridTableSection.firstNotEmptyRow2}}</argument>
26+
<argument name="modalAcceptButton">{{AdminConfirmationModalSection.ok}}</argument>
27+
<argument name="deleteButton">{{AdminMainActionsSection.delete}}</argument>
28+
<argument name="successMessageContainer">{{AdminMessagesSection.success}}</argument>
29+
<argument name="successMessage">You deleted the product attribute.</argument>
30+
</helper>
31+
<waitForElementVisible selector="{{AdminDataGridTableSection.dataGridEmpty}}" stepKey="waitDataGridEmptyMessageAppears"/>
32+
<see selector="{{AdminDataGridTableSection.dataGridEmpty}}" userInput="We couldn't find any records." stepKey="assertDataGridEmptyMessage"/>
33+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="clearExistingFiltersAgain"/>
34+
</actionGroup>
35+
</actionGroups>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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\Catalog\Test\Mftf\Helper;
9+
10+
use Facebook\WebDriver\Remote\RemoteWebDriver as FacebookWebDriver;
11+
use Facebook\WebDriver\WebDriverBy;
12+
use Magento\FunctionalTestingFramework\Helper\Helper;
13+
use Magento\FunctionalTestingFramework\Module\MagentoWebDriver;
14+
15+
/**
16+
* Class for MFTF helpers for Catalog module.
17+
*/
18+
class CatalogHelper extends Helper
19+
{
20+
/**
21+
* Delete all product attributes one by one.
22+
*
23+
* @param string $notEmptyRow
24+
* @param string $modalAcceptButton
25+
* @param string $deleteButton
26+
* @param string $successMessageContainer
27+
* @param string $successMessage
28+
* @retrun void
29+
*/
30+
public function deleteAllProductAttributesOneByOne(
31+
string $notEmptyRow,
32+
string $modalAcceptButton,
33+
string $deleteButton,
34+
string $successMessageContainer,
35+
string $successMessage
36+
): void {
37+
try {
38+
/** @var MagentoWebDriver $webDriver */
39+
$magentoWebDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
40+
/** @var FacebookWebDriver $webDriver */
41+
$webDriver = $magentoWebDriver->webDriver;
42+
$gridRows = $webDriver->findElements(WebDriverBy::cssSelector($notEmptyRow));
43+
while (!empty($gridRows)) {
44+
$gridRows[0]->click();
45+
$magentoWebDriver->waitForPageLoad(30);
46+
$magentoWebDriver->click($deleteButton);
47+
$magentoWebDriver->waitForPageLoad(30);
48+
$magentoWebDriver->waitForElementVisible($modalAcceptButton);
49+
$magentoWebDriver->click($modalAcceptButton);
50+
$magentoWebDriver->waitForPageLoad(60);
51+
$magentoWebDriver->waitForElementVisible($successMessageContainer);
52+
$magentoWebDriver->see($successMessage, $successMessageContainer);
53+
$gridRows = $webDriver->findElements(WebDriverBy::cssSelector($notEmptyRow));
54+
}
55+
} catch (\Exception $e) {
56+
$this->fail($e->getMessage());
57+
}
58+
}
59+
}

app/code/Magento/Persistent/Observer/EmulateCustomerObserver.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Persistent\Observer;
77

88
use Magento\Framework\Event\ObserverInterface;
9+
use Magento\Framework\Exception\NoSuchEntityException;
910

1011
/**
1112
* Class EmulateCustomer
@@ -86,9 +87,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
8687
/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
8788
$customer = $this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId());
8889
if ($defaultShipping = $customer->getDefaultShipping()) {
89-
/** @var \Magento\Customer\Model\Data\Address $address */
90-
$address = $this->addressRepository->getById($defaultShipping);
91-
if ($address) {
90+
$address = $this->getCustomerAddressById((int) $defaultShipping);
91+
92+
if ($address !== null) {
9293
$this->_customerSession->setDefaultTaxShippingAddress(
9394
[
9495
'country_id' => $address->getCountryId(),
@@ -102,8 +103,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
102103
}
103104

104105
if ($defaultBilling = $customer->getDefaultBilling()) {
105-
$address = $this->addressRepository->getById($defaultBilling);
106-
if ($address) {
106+
$address = $this->getCustomerAddressById((int) $defaultBilling);
107+
108+
if ($address !== null) {
107109
$this->_customerSession->setDefaultTaxBillingAddress([
108110
'country_id' => $address->getCountryId(),
109111
'region_id' => $address->getRegion() ? $address->getRegionId() : null,
@@ -118,4 +120,19 @@ public function execute(\Magento\Framework\Event\Observer $observer)
118120
}
119121
return $this;
120122
}
123+
124+
/**
125+
* Returns customer address by id
126+
*
127+
* @param int $addressId
128+
* @return \Magento\Customer\Api\Data\AddressInterface|null
129+
*/
130+
private function getCustomerAddressById(int $addressId)
131+
{
132+
try {
133+
return $this->addressRepository->getById($addressId);
134+
} catch (NoSuchEntityException $exception) {
135+
return null;
136+
}
137+
}
121138
}

app/code/Magento/Persistent/Test/Unit/Observer/EmulateCustomerObserverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ public function testExecuteWhenSessionPersistAndCustomerNotLoggedIn()
131131
$customerMock
132132
->expects($this->once())
133133
->method('getDefaultShipping')
134-
->willReturn('shippingId');
134+
->willReturn(12345);
135135
$customerMock
136136
->expects($this->once())
137137
->method('getDefaultBilling')
138-
->willReturn('billingId');
138+
->willReturn(12346);
139139
$valueMap = [
140-
['shippingId', $defaultShippingAddressMock],
141-
['billingId', $defaultBillingAddressMock]
140+
[12345, $defaultShippingAddressMock],
141+
[12346, $defaultBillingAddressMock]
142142
];
143143
$this->addressRepositoryMock->expects($this->any())->method('getById')->willReturnMap($valueMap);
144144
$this->customerSessionMock

app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
<element name="rowTemplateStrict" type="block" selector="//tbody/tr[td[*[text()[normalize-space()='{{text}}']]]]" parameterized="true" />
2323
<element name="rowTemplate" type="block" selector="//tbody/tr[td[*[contains(.,normalize-space('{{text}}'))]]]" parameterized="true" timeout="30" />
2424
<element name="firstNotEmptyRow" type="block" selector="table.data-grid tbody tr[data-role=row]:not(.data-grid-tr-no-data):nth-of-type(1)" timeout="30"/>
25+
<element name="firstNotEmptyRow2" type="block" selector="table.data-grid tbody tr:not(.data-grid-tr-no-data):nth-of-type(1)" timeout="30"/>
2526
</section>
2627
</sections>

app/code/Magento/Weee/Test/Mftf/Data/FixedProductAttributeData.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11-
<entity name="productFPTAttribute" type="ProductAttribute">
11+
<entity name="productFPTAttribute" type="ProductAttribute" deprecated="Use FPTProductAttribute instead">
1212
<data key="attribute_code" unique="suffix">attribute</data>
1313
<data key="is_unique">true</data>
1414
<data key="frontend_input">weee</data>
@@ -17,4 +17,13 @@
1717
<data key="is_filterable_in_grid">true</data>
1818
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
1919
</entity>
20+
<entity name="FPTProductAttribute" type="ProductAttribute">
21+
<data key="attribute_code" unique="suffix">weee_attribute</data>
22+
<data key="is_unique">true</data>
23+
<data key="frontend_input">weee</data>
24+
<data key="is_used_in_grid">true</data>
25+
<data key="is_visible_in_grid">true</data>
26+
<data key="is_filterable_in_grid">true</data>
27+
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabelWeee</requiredEntity>
28+
</entity>
2029
</entities>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="ProductAttributeFrontendLabelWeee" type="FrontendLabel">
12+
<data key="store_id">0</data>
13+
<data key="label" unique="suffix">weee-attribute</data>
14+
</entity>
15+
</entities>

app/code/Magento/Weee/Test/Mftf/Test/AdminFixedTaxValSavedForSpecificWebsiteTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<before>
2323
<!-- Create product attribute and add it to default attribute set />-->
2424
<comment userInput="Create product attribute and add it to default attribute set" stepKey="createAttrAndAddToDefaultAttrSet"/>
25-
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
25+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
2626
<createData entity="AddToDefaultSet" stepKey="addToDefaultAttributeSet">
2727
<requiredEntity createDataKey="createProductFPTAttribute"/>
2828
</createData>

app/code/Magento/Weee/Test/Mftf/Test/AdminRemoveProductWeeeAttributeOptionTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<group value="weee"/>
1919
</annotations>
2020
<before>
21-
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
21+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
2222
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
2323
<requiredEntity createDataKey="createProductFPTAttribute"/>
2424
</createData>

app/code/Magento/Weee/Test/Mftf/Test/StorefrontFPTTaxInformationInShoppingCartForCustomerPhysicalQuoteTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- Tax Rule is created based on default tax rates (Stores>Tax Rule) US-CA-*-Rate 1 = 8.2500 US-NY-*-Rate 1 = 8.3750 -->
2828
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
2929
<!-- Fixed Product Tax attribute is created and added to default attribute set -->
30-
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
30+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
3131
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
3232
<requiredEntity createDataKey="createProductFPTAttribute"/>
3333
</createData>

app/code/Magento/Weee/Test/Mftf/Test/StorefrontFPTTaxInformationInShoppingCartForCustomerVirtualQuoteTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- Tax Rule is created based on default tax rates (Stores>Tax Rule) US-CA-*-Rate 1 = 8.2500 US-NY-*-Rate 1 = 8.3750 -->
2828
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
2929
<!-- Fixed Product Tax attribute is created and added to default attribute set -->
30-
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
30+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
3131
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
3232
<requiredEntity createDataKey="createProductFPTAttribute"/>
3333
</createData>

app/code/Magento/Weee/Test/Mftf/Test/StorefrontFPTTaxInformationInShoppingCartForGuestPhysicalQuoteTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- Tax Rule is created based on default tax rates (Stores>Tax Rule) US-CA-*-Rate 1 = 8.2500 US-NY-*-Rate 1 = 8.3750 -->
2828
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
2929
<!-- Fixed Product Tax attribute is created and added to default attribute set -->
30-
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
30+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
3131
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
3232
<requiredEntity createDataKey="createProductFPTAttribute"/>
3333
</createData>

app/code/Magento/Weee/Test/Mftf/Test/StorefrontFPTTaxInformationInShoppingCartForGuestVirtualQuoteTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- Tax Rule is created based on default tax rates (Stores>Tax Rule) US-CA-*-Rate 1 = 8.2500 US-NY-*-Rate 1 = 8.3750 -->
2828
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
2929
<!-- Fixed Product Tax attribute is created and added to default attribute set -->
30-
<createData entity="productFPTAttribute" stepKey="createProductFPTAttribute"/>
30+
<createData entity="FPTProductAttribute" stepKey="createProductFPTAttribute"/>
3131
<createData entity="AddToDefaultSet" stepKey="addFPTToAttributeSet">
3232
<requiredEntity createDataKey="createProductFPTAttribute"/>
3333
</createData>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Backend\App\Area;
10+
11+
use PHPUnit\Framework\TestCase;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
/**
15+
* @magentoAppArea adminhtml
16+
*/
17+
class FrontNameResolverTest extends TestCase
18+
{
19+
/**
20+
* @var \Magento\Framework\ObjectManagerInterface
21+
*/
22+
protected $objectManager;
23+
24+
/**
25+
* @var FrontNameResolver
26+
*/
27+
protected $model;
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
protected function setUp(): void
33+
{
34+
$this->objectManager = Bootstrap::getObjectManager();
35+
$this->model = $this->objectManager->create(
36+
FrontNameResolver::class
37+
);
38+
$_SERVER['HTTP_HOST'] = 'localhost';
39+
}
40+
41+
/**
42+
* @magentoDbIsolation enabled
43+
* @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
44+
*/
45+
public function testIsHostBackend()
46+
{
47+
$this->assertTrue($this->model->isHostBackend());
48+
}
49+
}

0 commit comments

Comments
 (0)