currentCustomerMock = $this->getMockBuilder(\Magento\Customer\Helper\Session\CurrentCustomer::class) ->disableOriginalConstructor() ->getMock(); $this->customerAccountManagementMock = $this->getMockBuilder( \Magento\Customer\Api\AccountManagementInterface::class )->disableOriginalConstructor()->getMock(); $this->currentCustomerAddress = new \Magento\Customer\Helper\Session\CurrentCustomerAddress( $this->currentCustomerMock, $this->customerAccountManagementMock ); } /** * test getDefaultBillingAddress */ public function testGetDefaultBillingAddress() { $this->currentCustomerMock->expects($this->once()) ->method('getCustomerId') ->will($this->returnValue($this->customerCurrentId)); $this->customerAccountManagementMock->expects($this->once()) ->method('getDefaultBillingAddress') ->will($this->returnValue($this->customerAddressDataMock)); $this->assertEquals( $this->customerAddressDataMock, $this->currentCustomerAddress->getDefaultBillingAddress() ); } /** * test getDefaultShippingAddress */ public function testGetDefaultShippingAddress() { $this->currentCustomerMock->expects($this->once()) ->method('getCustomerId') ->will($this->returnValue($this->customerCurrentId)); $this->customerAccountManagementMock->expects($this->once()) ->method('getDefaultShippingAddress') ->will($this->returnValue($this->customerAddressDataMock)); $this->assertEquals( $this->customerAddressDataMock, $this->currentCustomerAddress->getDefaultShippingAddress() ); } }