Skip to content

Commit 01ce744

Browse files
committed
ACP2E-1121: PayPal Guest checkout Customer Email wrong graphql
1 parent f3c39e5 commit 01ce744

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,16 @@ protected function setUp(): void
240240
);
241241

242242
$this->quoteMock = $this->getMockBuilder(Quote::class)
243-
->addMethods(['setCustomerEmail', 'setCustomerGroupId', 'setCustomerId', 'setRemoteIp', 'setXForwardedFor'])
243+
->addMethods(
244+
[
245+
'setCustomerEmail',
246+
'setCustomerGroupId',
247+
'setCustomerId',
248+
'setRemoteIp',
249+
'setXForwardedFor',
250+
'getCustomerEmail'
251+
]
252+
)
244253
->onlyMethods(
245254
[
246255
'assignCustomer',
@@ -821,9 +830,10 @@ public function testSubmit(): void
821830
}
822831

823832
/**
833+
* @dataProvider guestPlaceOrderDataProvider
824834
* @return void
825835
*/
826-
public function testPlaceOrderIfCustomerIsGuest(): void
836+
public function testPlaceOrderIfCustomerIsGuest(?string $settledEmail, int $countSetAddress): void
827837
{
828838
$cartId = 100;
829839
$orderId = 332;
@@ -845,11 +855,17 @@ public function testPlaceOrderIfCustomerIsGuest(): void
845855
$this->quoteMock->expects($this->once())
846856
->method('getCustomer')
847857
->willReturn($customerMock);
858+
$this->quoteMock->expects($this->once())
859+
->method('getCustomerEmail')
860+
->willReturn($settledEmail);
848861
$this->quoteMock->expects($this->once())->method('setCustomerId')->with(null)->willReturnSelf();
849-
$this->quoteMock->expects($this->once())->method('setCustomerEmail')->with($email)->willReturnSelf();
862+
$this->quoteMock->expects($this->exactly($countSetAddress))
863+
->method('setCustomerEmail')
864+
->with($email)
865+
->willReturnSelf();
850866

851867
$addressMock = $this->createPartialMock(Address::class, ['getEmail']);
852-
$addressMock->expects($this->once())->method('getEmail')->willReturn($email);
868+
$addressMock->expects($this->exactly($countSetAddress))->method('getEmail')->willReturn($email);
853869
$this->quoteMock->expects($this->any())->method('getBillingAddress')->with()->willReturn($addressMock);
854870

855871
$this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf();
@@ -912,6 +928,17 @@ public function testPlaceOrderIfCustomerIsGuest(): void
912928
$this->assertEquals($orderId, $service->placeOrder($cartId));
913929
}
914930

931+
/**
932+
* @return array
933+
*/
934+
public function guestPlaceOrderDataProvider(): array
935+
{
936+
return [
937+
[null, 1],
938+
['test@example.com', 0],
939+
];
940+
}
941+
915942
/**
916943
* @return void
917944
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)

0 commit comments

Comments
 (0)