/**
  * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  * @expectedExceptionMessage Requested entity doesn't exist
  */
 public function testGetEntityNoId()
 {
     $id = 1;
     $entity = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Creditmemo')->disableOriginalConstructor()->getMock();
     $entity->expects($this->once())->method('load')->with($id)->willReturn($entity);
     $entity->expects($this->once())->method('getEntityId')->willReturn(null);
     $this->metadataMock->expects($this->once())->method('getNewInstance')->willReturn($entity);
     $this->assertNull($entity, $this->creditmemo->get($id));
 }
Example #2
0
 /**
  * Invoke creditmemo get service
  *
  * @param int $id
  * @return \Magento\Sales\Service\V1\Data\Creditmemo
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function invoke($id)
 {
     return $this->creditmemoMapper->extractDto($this->creditmemoRepository->get($id));
 }
Example #3
0
 /**
  * Invoke CreditmemoCancel service
  *
  * @param int $id
  * @return bool
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function invoke($id)
 {
     return (bool) $this->creditmemoRepository->get($id)->cancel();
 }
Example #4
0
 /**
  * Invoke notifyUser service
  *
  * @param int $id
  * @return bool
  */
 public function invoke($id)
 {
     /** @var \Magento\Sales\Model\Order\Creditmemo $creditmemo */
     $creditmemo = $this->creditmemoRepository->get($id);
     return $this->creditmemoNotifier->notify($creditmemo);
 }