Skip to content

Commit 1e6f2e6

Browse files
MAGETWO-93286: [2.3] Gift Message lost at Checkout when logging in
1 parent 4711dad commit 1e6f2e6

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use Magento\Catalog\Model\ProductRepository;
99
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
1010
use Magento\Framework\Exception\LocalizedException;
11-
use Magento\Quote\Api\Data\CartInterface;
1211
use Magento\TestFramework\Helper\Bootstrap;
1312
use Magento\TestFramework\ObjectManager;
1413
use Magento\Framework\Api\SearchCriteriaBuilder;
1514
use Magento\Quote\Api\CartRepositoryInterface;
15+
use Magento\Framework\Api\ExtensibleDataInterface;
1616

1717
/**
1818
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -32,7 +32,11 @@ protected function setUp()
3232
$this->objectManager = Bootstrap::getObjectManager();
3333
}
3434

35-
private function convertToArray($entity)
35+
/**
36+
* @param ExtensibleDataInterface $entity
37+
* @return array
38+
*/
39+
private function convertToArray(ExtensibleDataInterface $entity): array
3640
{
3741
return $this->objectManager
3842
->create(\Magento\Framework\Api\ExtensibleDataObjectConverter::class)
@@ -42,8 +46,9 @@ private function convertToArray($entity)
4246
/**
4347
* @magentoDataFixture Magento/Catalog/_files/product_virtual.php
4448
* @magentoDataFixture Magento/Sales/_files/quote.php
49+
* @return void
4550
*/
46-
public function testCollectTotalsWithVirtual()
51+
public function testCollectTotalsWithVirtual(): void
4752
{
4853
$quote = $this->objectManager->create(Quote::class);
4954
$quote->load('test01', 'reserved_order_id');
@@ -61,7 +66,10 @@ public function testCollectTotalsWithVirtual()
6166
$this->assertEquals(20, $quote->getBaseGrandTotal());
6267
}
6368

64-
public function testSetCustomerData()
69+
/**
70+
* @return void
71+
*/
72+
public function testSetCustomerData(): void
6573
{
6674
/** @var Quote $quote */
6775
$quote = $this->objectManager->create(Quote::class);
@@ -87,7 +95,10 @@ public function testSetCustomerData()
8795
$this->assertEquals('qa@example.com', $quote->getCustomerEmail());
8896
}
8997

90-
public function testUpdateCustomerData()
98+
/**
99+
* @return void
100+
*/
101+
public function testUpdateCustomerData(): void
91102
{
92103
/** @var Quote $quote */
93104
$quote = $this->objectManager->create(Quote::class);
@@ -133,8 +144,10 @@ public function testUpdateCustomerData()
133144

134145
/**
135146
* Customer data is set to quote (which contains valid group ID).
147+
*
148+
* @return void
136149
*/
137-
public function testGetCustomerGroupFromCustomer()
150+
public function testGetCustomerGroupFromCustomer(): void
138151
{
139152
/** Preconditions */
140153
/** @var CustomerInterfaceFactory $customerFactory */
@@ -154,8 +167,9 @@ public function testGetCustomerGroupFromCustomer()
154167

155168
/**
156169
* @magentoDataFixture Magento/Customer/_files/customer_group.php
170+
* @return void
157171
*/
158-
public function testGetCustomerTaxClassId()
172+
public function testGetCustomerTaxClassId(): void
159173
{
160174
/**
161175
* Preconditions: create quote and assign ID of customer group created in fixture to it.
@@ -179,8 +193,9 @@ public function testGetCustomerTaxClassId()
179193
* @magentoDataFixture Magento/Customer/_files/customer.php
180194
* @magentoDataFixture Magento/Customer/_files/customer_address.php
181195
* @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
196+
* @return void
182197
*/
183-
public function testAssignCustomerWithAddressChangeAddressesNotSpecified()
198+
public function testAssignCustomerWithAddressChangeAddressesNotSpecified(): void
184199
{
185200
/** Preconditions:
186201
* Customer with two addresses created
@@ -244,8 +259,9 @@ public function testAssignCustomerWithAddressChangeAddressesNotSpecified()
244259
* @magentoDataFixture Magento/Customer/_files/customer.php
245260
* @magentoDataFixture Magento/Customer/_files/customer_address.php
246261
* @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
262+
* @return void
247263
*/
248-
public function testAssignCustomerWithAddressChange()
264+
public function testAssignCustomerWithAddressChange(): void
249265
{
250266
/** Preconditions:
251267
* Customer with two addresses created
@@ -308,8 +324,9 @@ public function testAssignCustomerWithAddressChange()
308324

309325
/**
310326
* @magentoDataFixture Magento/Catalog/_files/product_simple_duplicated.php
327+
* @return void
311328
*/
312-
public function testAddProductUpdateItem()
329+
public function testAddProductUpdateItem(): void
313330
{
314331
/** @var Quote $quote */
315332
$quote = $this->objectManager->create(Quote::class);
@@ -353,10 +370,13 @@ public function testAddProductUpdateItem()
353370
* @param Quote $quote
354371
* @return \Magento\Customer\Api\Data\CustomerInterface
355372
*/
356-
protected function _prepareQuoteForTestAssignCustomerWithAddressChange($quote)
357-
{
373+
protected function _prepareQuoteForTestAssignCustomerWithAddressChange(
374+
Quote $quote
375+
): \Magento\Customer\Api\Data\CustomerInterface {
358376
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
359-
$customerRepository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
377+
$customerRepository = $this->objectManager->create(
378+
\Magento\Customer\Api\CustomerRepositoryInterface::class
379+
);
360380
$fixtureCustomerId = 1;
361381
/** @var \Magento\Customer\Model\Customer $customer */
362382
$customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class);
@@ -375,11 +395,11 @@ protected function _prepareQuoteForTestAssignCustomerWithAddressChange($quote)
375395
}
376396

377397
/**
378-
* @param $email
398+
* @param string $email
379399
* @param array $customerData
380400
* @return array
381401
*/
382-
protected function changeEmailInCustomerData($email, array $customerData)
402+
protected function changeEmailInCustomerData(string $email, array $customerData): array
383403
{
384404
$customerData[\Magento\Customer\Model\Data\Customer::EMAIL] = $email;
385405
return $customerData;
@@ -389,13 +409,16 @@ protected function changeEmailInCustomerData($email, array $customerData)
389409
* @param array $customerData
390410
* @return array
391411
*/
392-
protected function removeIdFromCustomerData(array $customerData)
412+
protected function removeIdFromCustomerData(array $customerData): array
393413
{
394414
unset($customerData[\Magento\Customer\Model\Data\Customer::ID]);
395415
return $customerData;
396416
}
397417

398-
protected function _getCustomerDataArray()
418+
/**
419+
* @return array
420+
*/
421+
protected function _getCustomerDataArray(): array
399422
{
400423
return [
401424
\Magento\Customer\Model\Data\Customer::CONFIRMATION => 'test',
@@ -425,8 +448,9 @@ protected function _getCustomerDataArray()
425448
*
426449
* @magentoDataFixture Magento/Sales/_files/order.php
427450
* @magentoDataFixture Magento/Quote/_files/empty_quote.php
451+
* @return void
428452
*/
429-
public function testReserveOrderId()
453+
public function testReserveOrderId(): void
430454
{
431455
/** @var Quote $quote */
432456
$quote = $this->objectManager->create(Quote::class);
@@ -441,8 +465,9 @@ public function testReserveOrderId()
441465
/**
442466
* Test to verify that disabled product cannot be added to cart
443467
* @magentoDataFixture Magento/Quote/_files/is_not_salable_product.php
468+
* @return void
444469
*/
445-
public function testAddedProductToQuoteIsSalable()
470+
public function testAddedProductToQuoteIsSalable(): void
446471
{
447472
$productId = 99;
448473

@@ -462,8 +487,9 @@ public function testAddedProductToQuoteIsSalable()
462487
/**
463488
* @magentoDataFixture Magento/Sales/_files/quote.php
464489
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
490+
* @return void
465491
*/
466-
public function testGetItemById()
492+
public function testGetItemById(): void
467493
{
468494
$quote = $this->objectManager->create(Quote::class);
469495
$quote->load('test01', 'reserved_order_id');
@@ -485,8 +511,9 @@ public function testGetItemById()
485511
* Tests of quotes merging.
486512
*
487513
* @magentoDataFixture Magento/Sales/_files/quote.php
514+
* @return void
488515
*/
489-
public function testMerge()
516+
public function testMerge(): void
490517
{
491518
$giftMessageId = 1;
492519

@@ -507,7 +534,7 @@ public function testMerge()
507534
* @param string $reservedOrderId
508535
* @return Quote
509536
*/
510-
private function getQuote($reservedOrderId)
537+
private function getQuote(string $reservedOrderId): Quote
511538
{
512539
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
513540
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);

0 commit comments

Comments
 (0)