예제 #1
0
 public function testSetCustomerAddressData()
 {
     $customerId = 1;
     $addressItemMock = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\Data\\Address')->disableOriginalConstructor()->getMock();
     $addresses = [$addressItemMock];
     $addressModelMock = $this->getMockBuilder('Magento\\Customer\\Model\\Address')->disableOriginalConstructor()->getMock();
     $this->addressConverterMock->expects($this->once())->method('createAddressModel')->with($addressItemMock)->will($this->returnValue($addressModelMock));
     $addressCollectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Address\\Collection')->disableOriginalConstructor()->getMock();
     $addressCollectionMock->expects($this->once())->method('removeAllItems');
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->getMock();
     $customerMock->expects($this->once())->method('load')->with($customerId);
     $customerMock->expects($this->once())->method('getId')->will($this->returnValue(false));
     $customerMock->expects($this->once())->method('getAddressesCollection')->will($this->returnValue($addressCollectionMock));
     $customerMock->expects($this->once())->method('addAddress')->with($addressModelMock);
     $this->customerFactoryMock->expects($this->once())->method('create')->will($this->returnValue($customerMock));
     $this->quote->setCustomerId($customerId);
     $result = $this->quote->setCustomerAddressData($addresses);
     $this->assertInstanceOf('Magento\\Sales\\Model\\Quote', $result);
 }