Skip to content

Commit e832db8

Browse files
authored
Merge branch '2.4-develop' into asi-1806
2 parents 9d0252a + 4ae0f74 commit e832db8

File tree

71 files changed

+5313
-518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5313
-518
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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="StorefrontCustomerCheckoutWithCustomerGroupTest">
11+
<annotations>
12+
<features value="Customer Checkout"/>
13+
<stories value="Customer checkout with Customer Group assigned"/>
14+
<title value="Place order by Customer with Customer Group assigned"/>
15+
<description value="Customer Group should be assigned to Order when setting Auto Group Assign is enabled for Customer"/>
16+
<testCaseId value="MC-37259"/>
17+
<severity value="MAJOR"/>
18+
<group value="checkout"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
23+
<magentoCLI command="config:set customer/create_account/auto_group_assign 1" stepKey="enableAutoGroupAssign"/>
24+
25+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
26+
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
30+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
31+
32+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
33+
34+
<actionGroup ref="AdminUpdateCustomerGroupByEmailActionGroup" stepKey="updateCustomerGroup">
35+
<argument name="emailAddress" value="$$createCustomer.email$$"/>
36+
<argument name="customerGroup" value="Retail"/>
37+
</actionGroup>
38+
39+
</before>
40+
<after>
41+
<magentoCLI command="config:set customer/create_account/auto_group_assign 0" stepKey="disableAutoGroupAssign"/>
42+
43+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
44+
<deleteData createDataKey="createCustomer" stepKey="deleteUsCustomer"/>
45+
<actionGroup ref="AdminClearCustomersFiltersActionGroup" stepKey="resetCustomerFilters"/>
46+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
47+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
48+
<deleteData createDataKey="createCategory" stepKey="deleteSimpleCategory"/>
49+
</after>
50+
51+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin">
52+
<argument name="Customer" value="$$createCustomer$$"/>
53+
</actionGroup>
54+
55+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage">
56+
<argument name="category" value="$$createCategory$$"/>
57+
</actionGroup>
58+
59+
<waitForPageLoad stepKey="waitForCatalogPageLoad"/>
60+
61+
<actionGroup ref="StorefrontAddCategoryProductToCartActionGroup" stepKey="addProductToCart">
62+
<argument name="product" value="$$createSimpleProduct$$"/>
63+
<argument name="productCount" value="CONST.one"/>
64+
</actionGroup>
65+
66+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
67+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/>
68+
<actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/>
69+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrder"/>
70+
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="clickOnPlaceOrder">
71+
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/>
72+
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/>
73+
</actionGroup>
74+
75+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="orderNumber"/>
76+
77+
<actionGroup ref="OpenOrderByIdActionGroup" stepKey="addFilterToGridAndOpenOrder">
78+
<argument name="orderId" value="{$orderNumber}"/>
79+
</actionGroup>
80+
81+
<see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="verifyOrderStatus"/>
82+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Customer" stepKey="verifyAccountInformation"/>
83+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="$$createCustomer.email$$" stepKey="verifyCustomerEmail"/>
84+
<see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Retail" stepKey="verifyCustomerGroup"/>
85+
<see selector="{{AdminOrderDetailsInformationSection.billingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="verifyBillingAddress"/>
86+
<see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="verifyShippingAddress"/>
87+
<see selector="{{AdminOrderDetailsInformationSection.itemsOrdered}}" userInput="$$createSimpleProduct.name$$" stepKey="verifyProductName"/>
88+
89+
</test>
90+
</tests>

app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1010
<actionGroup name="AdminOpenCmsPageActionGroup">
11+
<annotations>
12+
<description>Open CMS edit page.</description>
13+
</annotations>
1114
<arguments>
1215
<argument name="page_id" type="string"/>
1316
</arguments>

app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
119119

120120
$groupId = null;
121121
if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) {
122-
$groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup(
123-
$storeId
124-
)->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
122+
$groupId = $customer->getId() ? $quote->getCustomerGroupId() :
123+
$this->groupManagement->getNotLoggedInGroup()->getId();
125124
} else {
126125
// Magento always has to emulate group even if customer uses default billing/shipping address
127126
$groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber(

app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
1414
use Magento\Customer\Api\Data\GroupInterface;
1515
use Magento\Customer\Api\GroupManagementInterface;
16-
use Magento\Customer\Helper\Address;
16+
use Magento\Customer\Helper\Address as CustomerAddress;
1717
use Magento\Customer\Model\Session;
1818
use Magento\Customer\Model\Vat;
1919
use Magento\Framework\Event\Observer;
2020
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2121
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
2222
use Magento\Quote\Api\Data\ShippingInterface;
2323
use Magento\Quote\Model\Quote;
24+
use Magento\Quote\Model\Quote\Address;
2425
use Magento\Quote\Observer\Frontend\Quote\Address\CollectTotalsObserver;
2526
use Magento\Quote\Observer\Frontend\Quote\Address\VatValidator;
26-
use PHPUnit\Framework\MockObject\MockObject;
2727
use PHPUnit\Framework\TestCase;
28+
use PHPUnit\Framework\MockObject\MockObject;
2829

2930
/**
3031
* Class CollectTotalsTest
@@ -124,7 +125,7 @@ protected function setUp(): void
124125
true,
125126
['getStoreId', 'getCustomAttribute', 'getId', '__wakeup']
126127
);
127-
$this->customerAddressMock = $this->createMock(Address::class);
128+
$this->customerAddressMock = $this->createMock(CustomerAddress::class);
128129
$this->customerVatMock = $this->createMock(Vat::class);
129130
$this->customerDataFactoryMock = $this->getMockBuilder(CustomerInterfaceFactory::class)
130131
->addMethods(['mergeDataObjectWithArray'])
@@ -174,6 +175,7 @@ protected function setUp(): void
174175

175176
$shippingAssignmentMock = $this->getMockForAbstractClass(ShippingAssignmentInterface::class);
176177
$shippingMock = $this->getMockForAbstractClass(ShippingInterface::class);
178+
177179
$shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock);
178180
$shippingMock->expects($this->once())->method('getAddress')->willReturn($this->quoteAddressMock);
179181

@@ -185,7 +187,6 @@ protected function setUp(): void
185187
$this->quoteMock->expects($this->any())
186188
->method('getCustomer')
187189
->willReturn($this->customerMock);
188-
189190
$this->addressRepository = $this->getMockForAbstractClass(AddressRepositoryInterface::class);
190191
$this->customerSession = $this->getMockBuilder(Session::class)
191192
->disableOriginalConstructor()
@@ -266,26 +267,20 @@ public function testDispatchWithDefaultCustomerGroupId()
266267
->willReturn('customerCountryCode');
267268
$this->quoteAddressMock->expects($this->once())->method('getVatId')->willReturn(null);
268269

269-
$this->quoteMock->expects($this->once())
270+
$this->quoteMock->expects($this->exactly(2))
270271
->method('getCustomerGroupId')
271272
->willReturn('customerGroupId');
272273
$this->customerMock->expects($this->once())->method('getId')->willReturn('1');
273-
$this->groupManagementMock->expects($this->once())
274-
->method('getDefaultGroup')
275-
->willReturn($this->groupInterfaceMock);
276-
$this->groupInterfaceMock->expects($this->once())
277-
->method('getId')->willReturn('defaultCustomerGroupId');
274+
278275
/** Assertions */
279276
$this->quoteAddressMock->expects($this->once())
280277
->method('setPrevQuoteCustomerGroupId')
281278
->with('customerGroupId');
282-
$this->quoteMock->expects($this->once())->method('setCustomerGroupId')->with('defaultCustomerGroupId');
283279
$this->customerDataFactoryMock->expects($this->any())
284280
->method('create')
285281
->willReturn($this->customerMock);
286282

287283
$this->quoteMock->expects($this->once())->method('setCustomer')->with($this->customerMock);
288-
289284
/** SUT execution */
290285
$this->model->execute($this->observerMock);
291286
}
@@ -343,7 +338,7 @@ public function testDispatchWithAddressCustomerVatIdAndCountryId()
343338
$customerVat = "123123123";
344339
$defaultShipping = 1;
345340

346-
$customerAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
341+
$customerAddress = $this->createMock(Address::class);
347342
$customerAddress->expects($this->any())
348343
->method("getVatId")
349344
->willReturn($customerVat);
@@ -379,8 +374,8 @@ public function testDispatchWithEmptyShippingAddress()
379374
$customerCountryCode = "DE";
380375
$customerVat = "123123123";
381376
$defaultShipping = 1;
382-
383377
$customerAddress = $this->getMockForAbstractClass(AddressInterface::class);
378+
384379
$customerAddress->expects($this->once())
385380
->method("getCountryId")
386381
->willReturn($customerCountryCode);

app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ private function findRelations(array $products, array $loadAttributes, int $link
110110
//Matching products with related products.
111111
$relationsData = [];
112112
foreach ($relations as $productId => $relatedIds) {
113+
//Remove related products that not exist in map list.
114+
$relatedIds = array_filter($relatedIds, function ($relatedId) use ($relatedProducts) {
115+
return isset($relatedProducts[$relatedId]);
116+
});
113117
$relationsData[$productId] = array_map(
114118
function ($id) use ($relatedProducts) {
115119
return $relatedProducts[$id];

app/code/Magento/Wishlist/Model/Wishlist/Data/WishlistItemFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class WishlistItemFactory
2424
public function create(array $data): WishlistItem
2525
{
2626
return new WishlistItem(
27-
$data['quantity'],
27+
$data['quantity'] ?? 0,
2828
$data['sku'] ?? null,
2929
$data['parent_sku'] ?? null,
3030
isset($data['wishlist_item_id']) ? (int) $data['wishlist_item_id'] : null,

dev/tests/api-functional/testsuite/Magento/GraphQl/RelatedProduct/GetRelatedProductsTest.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\TestFramework\TestCase\GraphQlAbstract;
1111

1212
/**
13-
* Get related products test
13+
* Test coverage for get related products
1414
*/
1515
class GetRelatedProductsTest extends GraphQlAbstract
1616
{
@@ -49,6 +49,40 @@ public function testQueryRelatedProducts()
4949
self::assertRelatedProducts($relatedProducts);
5050
}
5151

52+
/**
53+
* @magentoApiDataFixture Magento/Catalog/_files/products_related_disabled.php
54+
*/
55+
public function testQueryDisableRelatedProduct()
56+
{
57+
$productSku = 'simple_with_cross';
58+
59+
$query = <<<QUERY
60+
{
61+
products(filter: {sku: {eq: "{$productSku}"}})
62+
{
63+
items {
64+
related_products
65+
{
66+
sku
67+
name
68+
url_key
69+
created_at
70+
}
71+
}
72+
}
73+
}
74+
QUERY;
75+
$response = $this->graphQlQuery($query);
76+
77+
self::assertArrayHasKey('products', $response);
78+
self::assertArrayHasKey('items', $response['products']);
79+
self::assertCount(1, $response['products']['items']);
80+
self::assertArrayHasKey(0, $response['products']['items']);
81+
self::assertArrayHasKey('related_products', $response['products']['items'][0]);
82+
$relatedProducts = $response['products']['items'][0]['related_products'];
83+
self::assertCount(0, $relatedProducts);
84+
}
85+
5286
/**
5387
* @magentoApiDataFixture Magento/Catalog/_files/products_crosssell.php
5488
*/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\TestFramework\Core\Version;
9+
10+
/**
11+
* Class for magento version flag.
12+
*/
13+
class View
14+
{
15+
/**
16+
* Returns flag that checks that magento version is clean community version.
17+
*
18+
* @return bool
19+
*/
20+
public function isVersionUpdated(): bool
21+
{
22+
return false;
23+
}
24+
}

0 commit comments

Comments
 (0)