示例#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
 /**
  * test _beforeSaveMethod via save() with failed validation
  *
  * @expectedException \Magento\Framework\Model\Exception
  * @expectedExceptionMessage Cannot save address:
  */
 public function testSaveValidationFailed()
 {
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->addressMock))->will($this->returnValue(['warning message']));
     $this->addressResource->save($this->addressMock);
     $this->assertTrue(true);
 }