Skip to content

Commit f2a44b6

Browse files
authored
Merge branch 'magento-commerce:2.4-develop' into ACP2E-2066
2 parents de7c387 + ca30c47 commit f2a44b6

File tree

52 files changed

+1958
-1100
lines changed

Some content is hidden

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

52 files changed

+1958
-1100
lines changed

app/code/Magento/Bundle/Test/Mftf/Data/ProductData.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
<data key="fixedPriceFormatted">$10.00</data>
3232
<data key="defaultAttribute">Default</data>
3333
</entity>
34+
<entity name="BundleProductWithSlashSku" type="product">
35+
<data key="name">BundleProduct</data>
36+
<data key="sku">bu/ndle</data>
37+
<data key="status">1</data>
38+
</entity>
3439
<entity name="FixedBundleProduct" type="product2">
3540
<data key="name" unique="suffix">FixedBundleProduct</data>
3641
<data key="sku" unique="suffix">fixed-bundle-product</data>

app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaCheckoutWithEnabledCaptchaTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</actionGroup>
5858
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="navigateToCheckout"/>
5959
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/>
60-
<actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/>
60+
<actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="goToReview"/>
6161
<actionGroup ref="AssertCaptchaVisibleOnSecondCheckoutStepActionGroup" stepKey="assertCaptchaIsVisible"/>
6262
<waitForPageLoad stepKey="waitForSpinner"/>
6363
<actionGroup ref="StorefrontFillCaptchaFieldOnCheckoutActionGroup" stepKey="placeOrderWithIncorrectValue">

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCategoryIndexerInUpdateOnScheduleModeTest.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494

9595
<!-- 4. Run cron to reindex -->
9696
<wait time="60" stepKey="waitForChanges"/>
97-
<magentoCLI command="cron:run --group index" stepKey="runCron"/>
98-
<magentoCLI command="cron:run --group index" stepKey="runCronTwice"/>
97+
<magentoCron groups="index" stepKey="runCron" />
98+
<magentoCron groups="index" stepKey="runCronTwice" />
9999

100100
<!-- 5. Open category A on Storefront again -->
101101
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadCategoryA"/>
@@ -124,8 +124,8 @@
124124

125125
<!-- 8. Run cron reindex (Ensure that at least one minute passed since last cron run) -->
126126
<wait time="60" stepKey="waitOneMinute"/>
127-
<magentoCLI command="cron:run --group index" stepKey="runCron1"/>
128-
<magentoCLI command="cron:run --group index" stepKey="runCronTwice1"/>
127+
<magentoCron groups="index" stepKey="runCron1" />
128+
<magentoCron groups="index" stepKey="runCronTwice1" />
129129

130130
<!-- 9. Open category A on Storefront again -->
131131
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshCategoryAPage"/>
@@ -180,8 +180,8 @@
180180

181181
<!-- 14. Run cron to reindex (Ensure that at least one minute passed since last cron run) -->
182182
<wait time="60" stepKey="waitMinute"/>
183-
<magentoCLI command="cron:run --group index" stepKey="runCron2"/>
184-
<magentoCLI command="cron:run --group index" stepKey="runCronTwice2"/>
183+
<magentoCron groups="index" stepKey="runCron2" />
184+
<magentoCron groups="index" stepKey="runCronTwice2" />
185185

186186
<!-- 15. Open category B on Storefront -->
187187
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="onPageCategoryB">
@@ -240,8 +240,8 @@
240240

241241
<!-- 17.14. Run cron to reindex (Ensure that at least one minute passed since last cron run) -->
242242
<wait time="60" stepKey="waitForOneMinute"/>
243-
<magentoCLI command="cron:run --group index" stepKey="runCron3"/>
244-
<magentoCLI command="cron:run --group index" stepKey="runCronTwice3"/>
243+
<magentoCron groups="index" stepKey="runCron3" />
244+
<magentoCron groups="index" stepKey="runCronTwice3" />
245245

246246
<!-- 17.15. Open category B on Storefront -->
247247
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="openPageCategoryB">
@@ -302,8 +302,8 @@
302302

303303
<!-- 18.14. Run cron to reindex (Ensure that at least one minute passed since last cron run) -->
304304
<wait time="60" stepKey="waitExtraMinute"/>
305-
<magentoCLI command="cron:run --group index" stepKey="runCron4"/>
306-
<magentoCLI command="cron:run --group index" stepKey="runCronTwice4"/>
305+
<magentoCron groups="index" stepKey="runCron4" />
306+
<magentoCron groups="index" stepKey="runCronTwice4" />
307307

308308
<!-- 18.15. Open category B on Storefront -->
309309
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="navigateToPageCategoryB">

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontVerifyProductAfterPartialReindexOnSeveralWebsitesTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
</actionGroup>
8383

8484
<!-- Run cron -->
85-
<magentoCLI command="cron:run" stepKey="runCron"/>
85+
<magentoCron stepKey="runCron" />
86+
<magentoCron stepKey="runCronTwice" />
8687

8788
<!-- Check product is present in category after cron run -->
8889
<actionGroup ref="AssertProductInStorefrontCategoryPage" stepKey="assertProductInStorefront1">

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/QuoteItemQtyList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class QuoteItemQtyList
3333
public function getQty($productId, $quoteItemId, $quoteId, $itemQty)
3434
{
3535
$qty = $itemQty;
36-
if (isset($this->_checkedQuoteItems[$quoteId][$productId]['qty']) && !in_array(
36+
if (isset($this->_checkedQuoteItems[$quoteId][$productId]['qty']) && $quoteItemId !== null && !in_array(
3737
$quoteItemId,
3838
$this->_checkedQuoteItems[$quoteId][$productId]['items']
3939
)

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/QuoteItemQtyListTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function testSingleQuoteItemQty()
4949

5050
$qty = $this->quoteItemQtyList->getQty(125, 1, 11232, 1);
5151
$this->assertEquals($this->itemQtyTestValue, $qty);
52+
53+
$this->itemQtyTestValue = 2;
54+
$qty = $this->quoteItemQtyList->getQty(125, null, 11232, 1);
55+
$this->assertNotEquals($this->itemQtyTestValue, $qty);
5256
}
5357

5458
/**

app/code/Magento/Checkout/Test/Mftf/ActionGroup/GuestCheckoutFillNewShippingAddressActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<fillField selector="{{CheckoutShippingSection.emailAddress}}" userInput="{{customer.email}}" stepKey="fillEmailField"/>
2121
<fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customer.firstName}}" stepKey="fillFirstName"/>
2222
<fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customer.lastName}}" stepKey="fillLastName"/>
23-
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{address.street}}" stepKey="fillStreet"/>
23+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{address.street[0]}}" stepKey="fillStreet"/>
2424
<fillField selector="{{CheckoutShippingSection.city}}" userInput="{{address.city}}" stepKey="fillCity"/>
2525
<selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{address.state}}" stepKey="selectRegion"/>
2626
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{address.postcode}}" stepKey="fillZipCode"/>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCheckoutClickNextOnShippingStepActionGroup.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11-
<actionGroup name="StorefrontCheckoutClickNextOnShippingStepActionGroup" extends="StorefrontCheckoutForwardFromShippingStepActionGroup">
11+
<actionGroup name="StorefrontCheckoutClickNextOnShippingStepActionGroup">
1212
<annotations>
1313
<description>Scrolls and clicks next on Checkout Shipping step</description>
1414
</annotations>
15-
<scrollTo selector="{{CheckoutShippingSection.next}}" before="clickNext" stepKey="scrollToNextButton"/>
15+
<waitForElement selector="{{CheckoutShippingSection.next}}" stepKey="waitForNextButtonElement"/>
16+
<scrollTo selector="{{CheckoutShippingSection.next}}" stepKey="scrollToNextButton"/>
17+
<waitForElementClickable selector="{{CheckoutShippingSection.next}}" stepKey="waitForNextButton"/>
18+
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
1619
<waitForPageLoad stepKey="waitForLoadingMaskToDisappear"/>
1720
</actionGroup>
1821
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCheckoutForwardFromShippingStepActionGroup.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11-
<actionGroup name="StorefrontCheckoutForwardFromShippingStepActionGroup">
11+
<actionGroup name="StorefrontCheckoutForwardFromShippingStepActionGroup" deprecated="[DEPRECATED] Please use StorefrontCheckoutClickNextOnShippingStepActionGroup">
1212
<annotations>
1313
<description>Clicks next on Checkout Shipping step</description>
1414
</annotations>
1515
<waitForElementClickable selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
1616
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
17+
<waitForPageLoad stepKey="waitForLoadingMaskToDisappear"/>
1718
</actionGroup>
1819
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithEnabledMinimumOrderAmountOptionTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/>
6868
<actionGroup ref="StorefrontClickProceedToCheckoutActionGroup" stepKey="goToCheckout"/>
6969
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/>
70-
<actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/>
70+
<actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="goToReview"/>
7171
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrder"/>
7272
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="clickOnPlaceOrder">
7373
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
5656
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/>
57-
<actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/>
57+
<actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="goToReview"/>
5858
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrder"/>
5959
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="clickOnPlaceOrder">
6060
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
6767
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/>
68-
<actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/>
68+
<actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="goToReview"/>
6969
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrder"/>
7070
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="clickOnPlaceOrder">
7171
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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\Customer\Test\Unit\ViewModel\Customer;
9+
10+
use Magento\Customer\ViewModel\Customer\Auth;
11+
use Magento\Framework\App\Http\Context;
12+
use PHPUnit\Framework\MockObject\MockObject;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class AuthTest extends TestCase
16+
{
17+
/**
18+
* @var Context|MockObject
19+
*/
20+
private mixed $contextMock;
21+
22+
/**
23+
* @var Auth
24+
*/
25+
private Auth $model;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
protected function setUp(): void
31+
{
32+
$this->contextMock = $this->getMockBuilder(Context::class)
33+
->disableOriginalConstructor()
34+
->getMock();
35+
36+
$this->model = new Auth(
37+
$this->contextMock
38+
);
39+
parent::setUp();
40+
}
41+
42+
/**
43+
* Test is logged in value.
44+
*
45+
* @return void
46+
*/
47+
public function testIsLoggedIn(): void
48+
{
49+
$this->contextMock->expects($this->once())
50+
->method('getValue')
51+
->willReturn(true);
52+
53+
$this->assertEquals(
54+
true,
55+
$this->model->isLoggedIn()
56+
);
57+
}
58+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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\Customer\Test\Unit\ViewModel\Customer;
9+
10+
use Magento\Customer\ViewModel\Customer\JsonSerializer;
11+
use Magento\Framework\Serialize\Serializer\Json as Json;
12+
use PHPUnit\Framework\MockObject\MockObject;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class JsonSerializerTest extends TestCase
16+
{
17+
/**
18+
* @var Json|MockObject
19+
*/
20+
private mixed $jsonEncoderMock;
21+
22+
/**
23+
* @var JsonSerializer
24+
*/
25+
private JsonSerializer $model;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
protected function setUp(): void
31+
{
32+
$this->jsonEncoderMock = $this->getMockBuilder(Json::class)
33+
->disableOriginalConstructor()
34+
->getMock();
35+
36+
$this->model = new JsonSerializer(
37+
$this->jsonEncoderMock
38+
);
39+
parent::setUp();
40+
}
41+
42+
/**
43+
* Test serialize value.
44+
*
45+
* @return void
46+
*/
47+
public function testSerialize(): void
48+
{
49+
$this->jsonEncoderMock->expects($this->once())
50+
->method('serialize')
51+
->willReturnCallback(
52+
function ($value) {
53+
return json_encode($value);
54+
}
55+
);
56+
57+
$this->assertEquals(
58+
json_encode(
59+
[
60+
'http://example.com/customer/section/load/'
61+
]
62+
),
63+
$this->model->serialize(['http://example.com/customer/section/load/'])
64+
);
65+
}
66+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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\Customer\ViewModel\Customer;
9+
10+
use Magento\Customer\Model\Context;
11+
use Magento\Framework\App\Http\Context as HttpContext;
12+
use Magento\Framework\View\Element\Block\ArgumentInterface;
13+
14+
/**
15+
* Customer's auth view model
16+
*/
17+
class Auth implements ArgumentInterface
18+
{
19+
/**
20+
* @param HttpContext $httpContext
21+
*/
22+
public function __construct(
23+
private HttpContext $httpContext
24+
) {
25+
}
26+
27+
/**
28+
* Check is user login
29+
*
30+
* @return bool
31+
*/
32+
public function isLoggedIn(): bool
33+
{
34+
return $this->httpContext->getValue(Context::CONTEXT_AUTH) ?? false;
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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\Customer\ViewModel\Customer;
9+
10+
use Magento\Framework\Serialize\Serializer\Json as Json;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
13+
/**
14+
* Customer's json serializer view model
15+
*/
16+
class JsonSerializer implements ArgumentInterface
17+
{
18+
/**
19+
* @param Json $jsonEncoder
20+
*/
21+
public function __construct(
22+
private Json $jsonEncoder
23+
) {
24+
}
25+
26+
/**
27+
* Encode the mixed $value into the JSON format
28+
*
29+
* @param mixed $value
30+
* @return string
31+
*/
32+
public function serialize(mixed $value): string
33+
{
34+
return $this->jsonEncoder->serialize($value);
35+
}
36+
}

app/code/Magento/Customer/view/frontend/layout/default.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
</arguments>
4949
</block>
5050
<block name="customer.customer.data" class="Magento\Customer\Block\CustomerData"
51-
template="Magento_Customer::js/customer-data.phtml"/>
51+
template="Magento_Customer::js/customer-data.phtml">
52+
<arguments>
53+
<argument name="auth" xsi:type="object">Magento\Customer\ViewModel\Customer\Auth</argument>
54+
<argument name="json_serializer" xsi:type="object">Magento\Customer\ViewModel\Customer\JsonSerializer</argument>
55+
</arguments>
56+
</block>
5257
<block name="customer.data.invalidation.rules" class="Magento\Customer\Block\CustomerScopeData"
5358
template="Magento_Customer::js/customer-data/invalidation-rules.phtml"/>
5459
</referenceContainer>

0 commit comments

Comments
 (0)