Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CurrentCustomerAddressTest.php
Go to the documentation of this file.
1 <?php
7 
8 class CurrentCustomerAddressTest extends \PHPUnit\Framework\TestCase
9 {
14 
19 
24 
29 
33  protected $customerCurrentId = 100;
34 
38  protected function setUp()
39  {
40  $this->currentCustomerMock = $this->getMockBuilder(\Magento\Customer\Helper\Session\CurrentCustomer::class)
41  ->disableOriginalConstructor()
42  ->getMock();
43  $this->customerAccountManagementMock = $this->getMockBuilder(
44  \Magento\Customer\Api\AccountManagementInterface::class
45  )->disableOriginalConstructor()->getMock();
46 
47  $this->currentCustomerAddress = new \Magento\Customer\Helper\Session\CurrentCustomerAddress(
48  $this->currentCustomerMock,
49  $this->customerAccountManagementMock
50  );
51  }
52 
56  public function testGetDefaultBillingAddress()
57  {
58  $this->currentCustomerMock->expects($this->once())
59  ->method('getCustomerId')
60  ->will($this->returnValue($this->customerCurrentId));
61 
62  $this->customerAccountManagementMock->expects($this->once())
63  ->method('getDefaultBillingAddress')
64  ->will($this->returnValue($this->customerAddressDataMock));
65  $this->assertEquals(
66  $this->customerAddressDataMock,
67  $this->currentCustomerAddress->getDefaultBillingAddress()
68  );
69  }
70 
75  {
76  $this->currentCustomerMock->expects($this->once())
77  ->method('getCustomerId')
78  ->will($this->returnValue($this->customerCurrentId));
79  $this->customerAccountManagementMock->expects($this->once())
80  ->method('getDefaultShippingAddress')
81  ->will($this->returnValue($this->customerAddressDataMock));
82  $this->assertEquals(
83  $this->customerAddressDataMock,
84  $this->currentCustomerAddress->getDefaultShippingAddress()
85  );
86  }
87 }