예제 #1
0
 /**
  * test _beforeSaveMethod via save() with failed validation
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage We can't save the address:
  */
 public function testSaveValidationFailed()
 {
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->addressMock)->willReturn(true);
     $this->addressMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->addressMock))->will($this->returnValue(['warning message']));
     $this->addressResource->save($this->addressMock);
 }
예제 #2
0
 /**
  * Run test validate
  *
  * @param $addressData
  * @param $email
  * @param $addressType
  * @param $expectedWarnings
  * @dataProvider providerAddressData
  */
 public function testValidate($addressData, $email, $addressType, $expectedWarnings)
 {
     $this->addressMock->expects($this->any())->method('hasData')->will($this->returnValueMap($addressData));
     $this->addressMock->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $this->addressMock->expects($this->once())->method('getAddressType')->will($this->returnValue($addressType));
     $actualWarnings = $this->validator->validate($this->addressMock);
     $this->assertEquals($expectedWarnings, $actualWarnings);
 }
예제 #3
0
 /**
  * test _beforeSaveMethod via save()
  */
 public function testSave()
 {
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->addressMock))->will($this->returnValue([]));
     $this->addressMock->expects($this->once())->method('hasDataChanges')->will($this->returnValue(true));
     $this->addressMock->expects($this->exactly(2))->method('getOrderId')->will($this->returnValue(2));
     $this->gridPoolMock->expects($this->once())->method('refreshByOrderId')->with($this->equalTo(2))->will($this->returnSelf());
     $this->addressResource->save($this->addressMock);
     $this->assertTrue(true);
 }
예제 #4
0
 /**
  * Test process method with shipping_address
  */
 public function testProcessShippingAddress()
 {
     $this->orderMock->expects($this->exactly(2))->method('getAddresses')->willReturn([$this->addressMock]);
     $this->addressMock->expects($this->once())->method('save')->will($this->returnSelf());
     $this->orderMock->expects($this->once())->method('getBillingAddress')->will($this->returnValue(null));
     $this->orderMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($this->addressMock));
     $this->addressMock->expects($this->exactly(2))->method('getId')->will($this->returnValue(2));
     $this->orderMock->expects($this->once())->method('setShippingAddressId')->will($this->returnSelf());
     $this->attributeMock->expects($this->once())->method('saveAttribute')->with($this->orderMock, ['shipping_address_id'])->will($this->returnSelf());
     $this->assertEquals($this->address, $this->address->process($this->orderMock));
 }