Skip to content

Commit 57c19b9

Browse files
committed
ACP2E-3028: Paylater message not showing in PDP for Canadian paypal merchant account
1 parent e0d523d commit 57c19b9

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*
7+
* ************************************************************************
8+
*/
9+
declare(strict_types=1);
10+
11+
namespace Magento\Paypal\Test\Unit\CustomerData;
12+
13+
use Magento\Customer\Api\AddressRepositoryInterface;
14+
use Magento\Customer\Api\Data\AddressInterface;
15+
use Magento\Customer\Api\Data\CustomerInterface;
16+
use Magento\Customer\Helper\Session\CurrentCustomer;
17+
use Magento\Framework\Exception\NoSuchEntityException;
18+
use Magento\Paypal\CustomerData\BuyerCountry;
19+
use PHPUnit\Framework\MockObject\MockObject;
20+
use PHPUnit\Framework\TestCase;
21+
22+
class BuyerCountryTest extends TestCase
23+
{
24+
/**
25+
* @var CurrentCustomer|MockObject
26+
*/
27+
private CurrentCustomer $currentCustomer;
28+
29+
/**
30+
* @var AddressRepositoryInterface|MockObject
31+
*/
32+
private AddressRepositoryInterface $addressRepository;
33+
34+
/**
35+
* @var BuyerCountry
36+
*/
37+
private BuyerCountry $buyerCountry;
38+
39+
/**
40+
* @return void
41+
*/
42+
protected function setUp(): void
43+
{
44+
$this->currentCustomer = $this->createMock(CurrentCustomer::class);
45+
$this->addressRepository = $this->createMock(AddressRepositoryInterface::class);
46+
47+
$this->buyerCountry = new BuyerCountry($this->currentCustomer, $this->addressRepository);
48+
}
49+
50+
/**
51+
* @return void
52+
*/
53+
public function testGetSectionDataException(): void
54+
{
55+
$customer = $this->createMock(CustomerInterface::class);
56+
$customer->expects($this->exactly(2))
57+
->method('getDefaultBilling')
58+
->willReturn(1);
59+
$this->currentCustomer->expects($this->once())
60+
->method('getCustomer')
61+
->willReturn($customer);
62+
$this->addressRepository->expects($this->once())
63+
->method('getById')
64+
->willThrowException(new NoSuchEntityException());
65+
66+
$this->assertEquals(['code' => null], $this->buyerCountry->getSectionData());
67+
}
68+
69+
/**
70+
* @return void
71+
*/
72+
public function testGetSectionDataNoAddress(): void
73+
{
74+
$customer = $this->createMock(CustomerInterface::class);
75+
$customer->expects($this->once())
76+
->method('getDefaultBilling')
77+
->willReturn(null);
78+
$customer->expects($this->once())
79+
->method('getDefaultShipping')
80+
->willReturn(null);
81+
$this->currentCustomer->expects($this->once())
82+
->method('getCustomer')
83+
->willReturn($customer);
84+
85+
$this->assertEquals(['code' => null], $this->buyerCountry->getSectionData());
86+
}
87+
88+
/**
89+
* @return void
90+
*/
91+
public function testGetSectionDataShippingAddress(): void
92+
{
93+
$customer = $this->createMock(CustomerInterface::class);
94+
$customer->expects($this->once())
95+
->method('getDefaultBilling')
96+
->willReturn(null);
97+
$customer->expects($this->once())
98+
->method('getDefaultShipping')
99+
->willReturn(1);
100+
$this->currentCustomer->expects($this->once())
101+
->method('getCustomer')
102+
->willReturn($customer);
103+
$address = $this->createMock(AddressInterface::class);
104+
$address->expects($this->once())
105+
->method('getCountryId')
106+
->willReturn('US');
107+
$this->addressRepository->expects($this->once())->method('getById')->willReturn($address);
108+
109+
$this->assertEquals(['code' => 'US'], $this->buyerCountry->getSectionData());
110+
}
111+
}

0 commit comments

Comments
 (0)