12 use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory;
46 $this->historyCollectionFactory = $this->createPartialMock(
50 $this->creditmemo = $this->createPartialMock(
52 [
'__wakeUp',
'getEmailSent']
54 $this->creditmemoSenderMock = $this->createPartialMock(
55 \
Magento\Sales\Model\
Order\Email\Sender\CreditmemoSender::class,
58 $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
60 $this->historyCollectionFactory,
62 $this->creditmemoSenderMock
71 $historyCollection = $this->createPartialMock(
73 [
'getUnnotifiedForInstance',
'save',
'setIsCustomerNotified']
75 $historyItem = $this->createPartialMock(
77 [
'setIsCustomerNotified',
'save',
'__wakeUp']
79 $historyItem->expects($this->at(0))
80 ->method(
'setIsCustomerNotified')
82 $historyItem->expects($this->at(1))
84 $historyCollection->expects($this->once())
85 ->method(
'getUnnotifiedForInstance')
86 ->with($this->creditmemo)
87 ->will($this->returnValue($historyItem));
88 $this->creditmemo->expects($this->once())
89 ->method(
'getEmailSent')
90 ->will($this->returnValue(
true));
91 $this->historyCollectionFactory->expects($this->once())
93 ->will($this->returnValue($historyCollection));
95 $this->creditmemoSenderMock->expects($this->once())
97 ->with($this->equalTo($this->creditmemo));
99 $this->assertTrue($this->notifier->notify($this->creditmemo));
107 $this->creditmemo->expects($this->once())
108 ->method(
'getEmailSent')
109 ->will($this->returnValue(
false));
110 $this->assertFalse($this->notifier->notify($this->creditmemo));
119 $this->creditmemoSenderMock->expects($this->once())
121 ->with($this->equalTo($this->creditmemo))
122 ->will($this->throwException($exception));
123 $this->loggerMock->expects($this->once())
125 ->with($this->equalTo($exception));
126 $this->assertFalse($this->notifier->notify($this->creditmemo));
$historyCollectionFactory