Skip to content

Commit df72ab3

Browse files
committed
MC-34039: Merge 2.4-develop into 2.4-develop-php74
-- fix merge conflicts
1 parent 2ad98a5 commit df72ab3

File tree

18 files changed

+536
-432
lines changed

18 files changed

+536
-432
lines changed

app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/StockTest.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ class StockTest extends TestCase
7272
*/
7373
private $statementMock;
7474

75+
/**
76+
* @inheritDoc
77+
*/
7578
protected function setUp(): void
7679
{
7780
$objectManager = new ObjectManager($this);
@@ -117,23 +120,35 @@ protected function setUp(): void
117120
* @param array $productIds
118121
* @param array $products
119122
* @param array $result
123+
* @param array $items
120124
*
121125
* @return void
122126
*/
123-
public function testLockProductsStock(int $websiteId, array $productIds, array $products, array $result)
124-
{
125-
$this->selectMock->expects($this->exactly(2))
127+
public function testLockProductsStock(
128+
int $websiteId,
129+
array $productIds,
130+
array $products,
131+
array $result,
132+
array $items
133+
) {
134+
$itemIds = [];
135+
foreach ($items as $item) {
136+
$itemIds[] = $item['item_id'];
137+
}
138+
$this->selectMock->expects($this->exactly(3))
126139
->method('from')
127140
->withConsecutive(
141+
[$this->identicalTo(self::ITEM_TABLE)],
128142
[$this->identicalTo(['si' => self::ITEM_TABLE])],
129143
[$this->identicalTo(['p' => self::PRODUCT_TABLE]), $this->identicalTo([])]
130144
)
131145
->willReturnSelf();
132-
$this->selectMock->expects($this->exactly(3))
146+
$this->selectMock->expects($this->exactly(4))
133147
->method('where')
134148
->withConsecutive(
135149
[$this->identicalTo('website_id = ?'), $this->identicalTo($websiteId)],
136150
[$this->identicalTo('product_id IN(?)'), $this->identicalTo($productIds)],
151+
[$this->identicalTo('item_id IN (?)'), $this->identicalTo($itemIds)],
137152
[$this->identicalTo('entity_id IN (?)'), $this->identicalTo($productIds)]
138153
)
139154
->willReturnSelf();
@@ -145,14 +160,17 @@ public function testLockProductsStock(int $websiteId, array $productIds, array $
145160
->method('columns')
146161
->with($this->identicalTo(['product_id' => 'entity_id', 'type_id' => 'type_id']))
147162
->willReturnSelf();
148-
$this->connectionMock->expects($this->exactly(2))
163+
$this->connectionMock->expects($this->exactly(3))
149164
->method('select')
150165
->willReturn($this->selectMock);
151-
$this->connectionMock->expects($this->once())
166+
$this->connectionMock->expects($this->exactly(2))
152167
->method('query')
153168
->with($this->identicalTo($this->selectMock))
154169
->willReturn($this->statementMock);
155-
$this->statementMock->expects($this->once())
170+
$this->statementMock->expects($this->at(0))
171+
->method('fetchAll')
172+
->willReturn($items);
173+
$this->statementMock->expects($this->at(1))
156174
->method('fetchAll')
157175
->willReturn($products);
158176
$this->connectionMock->expects($this->once())
@@ -168,7 +186,7 @@ public function testLockProductsStock(int $websiteId, array $productIds, array $
168186
self::ITEM_TABLE,
169187
self::PRODUCT_TABLE
170188
));
171-
$this->stock->expects($this->exactly(4))
189+
$this->stock->expects($this->exactly(6))
172190
->method('getConnection')
173191
->willReturn($this->connectionMock);
174192

@@ -205,6 +223,7 @@ public function productsDataProvider(): array
205223
'type_id' => 'simple',
206224
],
207225
],
226+
[['item_id' => 1], ['item_id' => 2], ['item_id' => 3]]
208227
],
209228
];
210229
}

app/code/Magento/Checkout/Test/Unit/CustomerData/DefaultItemTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,6 @@ public function testGetItemData()
115115
$this->assertArrayHasKey('product_price_value', $itemData);
116116
$this->assertArrayHasKey('product_image', $itemData);
117117
$this->assertArrayHasKey('canApplyMsrp', $itemData);
118+
$this->assertArrayHasKey('message', $itemData);
118119
}
119120
}

app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Magento\Framework\Controller\ResultFactory;
2626
use Magento\Framework\Message\Manager;
2727
use Magento\Framework\Message\ManagerInterface;
28+
use Magento\Framework\Phrase;
2829
use Magento\Framework\Stdlib\Cookie\CookieMetadata;
2930
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
3031
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
@@ -267,11 +268,11 @@ public function getParametersDataProvider()
267268
* @param $key
268269
* @param $vatValidationEnabled
269270
* @param $addressType
270-
* @param $successMessage
271-
*
271+
* @param Phrase $successMessage
272+
* @throws \ReflectionException
272273
* @dataProvider getSuccessMessageDataProvider
273274
*/
274-
public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $addressType, $successMessage)
275+
public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $addressType, Phrase $successMessage)
275276
{
276277
$this->customerSessionMock->expects($this->once())
277278
->method('isLoggedIn')
@@ -306,10 +307,22 @@ public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $ad
306307
->with($this->customerDataMock)
307308
->willReturnSelf();
308309

309-
$this->messageManagerMock->expects($this->any())
310-
->method('addSuccessMessage')
310+
$this->messageManagerMock
311+
->method('addSuccess')
312+
->with($successMessage)
311313
->willReturnSelf();
312314

315+
$this->messageManagerMock
316+
->expects($this->never())
317+
->method('addException');
318+
319+
$this->urlMock
320+
->method('getUrl')
321+
->willReturnMap([
322+
['customer/address/edit', null, 'http://store.web/customer/address/edit'],
323+
['*/*/admin', ['_secure' => true], 'http://store.web/back']
324+
]);
325+
313326
$this->addressHelperMock->expects($this->once())
314327
->method('isVatValidationEnabled')
315328
->willReturn($vatValidationEnabled);
@@ -365,9 +378,29 @@ public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $ad
365378
public function getSuccessMessageDataProvider()
366379
{
367380
return [
368-
[1, 1, false, null, (string)__('Thank you for registering with')],
369-
[1, 1, true, Address::TYPE_BILLING, (string)__('enter your billing address for proper VAT calculation')],
370-
[1, 1, true, Address::TYPE_SHIPPING, (string)__('enter your shipping address for proper VAT calculation')],
381+
[1, 1, false, null, __('Thank you for registering with %1.', 'frontend')],
382+
[
383+
1,
384+
1,
385+
true,
386+
Address::TYPE_BILLING,
387+
__(
388+
'If you are a registered VAT customer, please click <a href="%1">here</a>'
389+
. ' to enter your billing address for proper VAT calculation.',
390+
'http://store.web/customer/address/edit'
391+
)
392+
],
393+
[
394+
1,
395+
1,
396+
true,
397+
Address::TYPE_SHIPPING,
398+
__(
399+
'If you are a registered VAT customer, please click <a href="%1">here</a>'
400+
. ' to enter your shipping address for proper VAT calculation.',
401+
'http://store.web/customer/address/edit'
402+
)
403+
],
371404
];
372405
}
373406

@@ -378,8 +411,8 @@ public function getSuccessMessageDataProvider()
378411
* @param $successUrl
379412
* @param $resultUrl
380413
* @param $isSetFlag
381-
* @param $successMessage
382-
*
414+
* @param Phrase $successMessage
415+
* @throws \ReflectionException
383416
* @dataProvider getSuccessRedirectDataProvider
384417
*/
385418
public function testSuccessRedirect(
@@ -389,7 +422,7 @@ public function testSuccessRedirect(
389422
$successUrl,
390423
$resultUrl,
391424
$isSetFlag,
392-
$successMessage
425+
Phrase $successMessage
393426
) {
394427
$this->customerSessionMock->expects($this->once())
395428
->method('isLoggedIn')
@@ -425,22 +458,30 @@ public function testSuccessRedirect(
425458
->with($this->customerDataMock)
426459
->willReturnSelf();
427460

428-
$this->messageManagerMock->expects($this->any())
429-
->method('addSuccessMessage')
461+
$this->messageManagerMock
462+
->method('addSuccess')
463+
->with($successMessage)
430464
->willReturnSelf();
431465

466+
$this->messageManagerMock
467+
->expects($this->never())
468+
->method('addException');
469+
470+
$this->urlMock
471+
->method('getUrl')
472+
->willReturnMap([
473+
['customer/address/edit', null, 'http://store.web/customer/address/edit'],
474+
['*/*/admin', ['_secure' => true], 'http://store.web/back'],
475+
['*/*/index', ['_secure' => true], $successUrl]
476+
]);
477+
432478
$this->storeMock->expects($this->any())
433479
->method('getFrontendName')
434480
->willReturn('frontend');
435481
$this->storeManagerMock->expects($this->any())
436482
->method('getStore')
437483
->willReturn($this->storeMock);
438484

439-
$this->urlMock->expects($this->any())
440-
->method('getUrl')
441-
->with('*/*/index', ['_secure' => true])
442-
->willReturn($successUrl);
443-
444485
$this->redirectMock->expects($this->once())
445486
->method('success')
446487
->with($resultUrl)
@@ -483,7 +524,7 @@ public function getSuccessRedirectDataProvider()
483524
null,
484525
'http://example.com/back',
485526
true,
486-
(string)__('Thank you for registering with'),
527+
__('Thank you for registering with %1.', 'frontend'),
487528
],
488529
[
489530
1,
@@ -492,7 +533,7 @@ public function getSuccessRedirectDataProvider()
492533
'http://example.com/success',
493534
'http://example.com/success',
494535
true,
495-
(string)__('Thank you for registering with'),
536+
__('Thank you for registering with %1.', 'frontend'),
496537
],
497538
[
498539
1,
@@ -501,7 +542,7 @@ public function getSuccessRedirectDataProvider()
501542
'http://example.com/success',
502543
'http://example.com/success',
503544
false,
504-
(string)__('Thank you for registering with'),
545+
__('Thank you for registering with %1.', 'frontend'),
505546
],
506547
];
507548
}

app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,14 +566,12 @@ protected function mockExceptions($exception, $username)
566566
->with($username)
567567
->willReturn($url);
568568

569-
$message = __(
570-
'This account is not confirmed.' .
571-
' <a href="%1">Click here</a> to resend confirmation email.',
572-
$url
573-
);
574569
$this->messageManager->expects($this->once())
575-
->method('addErrorMessage')
576-
->with($message)
570+
->method('addComplexErrorMessage')
571+
->with(
572+
'confirmAccountErrorMessage',
573+
['url' => $url]
574+
)
577575
->willReturnSelf();
578576

579577
$this->session->expects($this->once())

app/code/Magento/Customer/Test/Unit/Controller/Address/SaveTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
@@ -165,9 +164,8 @@ public function testExecute(): void
165164
->withConsecutive(['parent_id'], ['entity_id'])
166165
->willReturnOnConsecutiveCalls(22, 1);
167166

168-
$customerMock = $this->getMockBuilder(
169-
CustomerInterface::class
170-
)->disableOriginalConstructor()
167+
$customerMock = $this->getMockBuilder(CustomerInterface::class)
168+
->disableOriginalConstructor()
171169
->getMock();
172170

173171
$this->customerRepositoryMock->expects($this->atLeastOnce())
@@ -214,7 +212,7 @@ public function testExecute(): void
214212
->method('setData')
215213
->with(
216214
[
217-
'message' => __('Customer address has been updated.'),
215+
'messages' => __('Customer address has been updated.'),
218216
'error' => false,
219217
'data' => [
220218
'entity_id' => $addressId

0 commit comments

Comments
 (0)