/** * @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)); }
/** * 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)); }
/** * Invoke CreditmemoCancel service * * @param int $id * @return bool * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function invoke($id) { return (bool) $this->creditmemoRepository->get($id)->cancel(); }
/** * 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); }