12 use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory;
46 $this->historyCollectionFactory = $this->createPartialMock(
50 $this->order = $this->createPartialMock(\
Magento\Sales\Model\Order::class, [
'__wakeUp',
'getEmailSent']);
51 $this->orderSenderMock = $this->createPartialMock(
52 \
Magento\Sales\Model\
Order\Email\Sender\OrderSender::class,
55 $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
57 $this->historyCollectionFactory,
59 $this->orderSenderMock
68 $historyCollection = $this->createPartialMock(
70 [
'getUnnotifiedForInstance',
'save',
'setIsCustomerNotified']
72 $historyItem = $this->createPartialMock(
74 [
'setIsCustomerNotified',
'save',
'__wakeUp']
76 $historyItem->expects($this->at(0))
77 ->method(
'setIsCustomerNotified')
79 $historyItem->expects($this->at(1))
81 $historyCollection->expects($this->once())
82 ->method(
'getUnnotifiedForInstance')
84 ->will($this->returnValue($historyItem));
85 $this->order->expects($this->once())
86 ->method(
'getEmailSent')
87 ->will($this->returnValue(
true));
88 $this->historyCollectionFactory->expects($this->once())
90 ->will($this->returnValue($historyCollection));
92 $this->orderSenderMock->expects($this->once())
94 ->with($this->equalTo($this->order));
96 $this->assertTrue($this->notifier->notify($this->order));
104 $this->order->expects($this->once())
105 ->method(
'getEmailSent')
106 ->will($this->returnValue(
false));
107 $this->assertFalse($this->notifier->notify($this->order));
116 $this->orderSenderMock->expects($this->once())
118 ->with($this->equalTo($this->order))
119 ->will($this->throwException($exception));
120 $this->loggerMock->expects($this->once())
122 ->with($this->equalTo($exception));
123 $this->assertFalse($this->notifier->notify($this->order));
$historyCollectionFactory