Esempio n. 1
0
 /**
  * @magentoAppIsolation enabled
  * @magentoDbIsolation enabled
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoDataFixture Magento/Customer/_files/customer_address.php
  */
 public function testSaveShippingWithCustomerId()
 {
     $this->_currentQuote->setCustomerId(1)->save();
     $data = array('address_id' => '', 'firstname' => 'Joe', 'lastname' => 'Black', 'company' => 'Lunatis', 'street' => array('1100 Parmer', 'ln.'), 'city' => 'Austin', 'region_id' => '57', 'region' => '', 'postcode' => '78757', 'country_id' => 'US', 'telephone' => '(512) 999-9999', 'fax' => '', 'save_in_address_book' => 1);
     $this->_model->saveShipping($data, 1);
     $address = $this->_currentQuote->getShippingAddress();
     /* Verify that data from Customer Address identified by id=1 is set */
     $this->assertEquals('John', $address->getFirstname());
     $this->assertEquals('Smith', $address->getLastname());
     $this->assertEquals(array('Green str, 67'), $address->getStreet());
     $this->assertEquals('CityM', $address->getCity());
     $this->assertEquals('Alabama', $address->getRegion());
     $this->assertEquals(1, $address->getRegionId());
     $this->assertEquals('75477', $address->getPostcode());
     $this->assertEquals('US', $address->getCountryId());
     $this->assertEquals('3468676', $address->getTelephone());
     $this->assertEquals('*****@*****.**', $address->getEmail());
     $this->assertTrue($address->getCollectShippingRates());
     $this->assertEquals(1, $address->getCustomerAddressId());
 }
Esempio n. 2
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);
 }