10 use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory;
47 $this->historyCollectionFactory = $this->createPartialMock(
51 $this->shipment = $this->createPartialMock(
53 [
'__wakeUp',
'getEmailSent']
55 $this->shipmentSenderMock = $this->createPartialMock(
56 \
Magento\Sales\Model\
Order\Email\Sender\ShipmentSender::class,
59 $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
61 $this->historyCollectionFactory,
63 $this->shipmentSenderMock
72 $historyCollection = $this->createPartialMock(
74 [
'getUnnotifiedForInstance',
'save',
'setIsCustomerNotified']
76 $historyItem = $this->createPartialMock(
78 [
'setIsCustomerNotified',
'save',
'__wakeUp']
80 $historyItem->expects($this->at(0))
81 ->method(
'setIsCustomerNotified')
83 $historyItem->expects($this->at(1))
85 $historyCollection->expects($this->once())
86 ->method(
'getUnnotifiedForInstance')
87 ->with($this->shipment)
88 ->will($this->returnValue($historyItem));
89 $this->shipment->expects($this->once())
90 ->method(
'getEmailSent')
91 ->will($this->returnValue(
true));
92 $this->historyCollectionFactory->expects($this->once())
94 ->will($this->returnValue($historyCollection));
96 $this->shipmentSenderMock->expects($this->once())
98 ->with($this->equalTo($this->shipment));
100 $this->assertTrue($this->notifier->notify($this->shipment));
108 $this->shipment->expects($this->once())
109 ->method(
'getEmailSent')
110 ->will($this->returnValue(
false));
111 $this->assertFalse($this->notifier->notify($this->shipment));
120 $this->shipmentSenderMock->expects($this->once())
122 ->with($this->equalTo($this->shipment))
123 ->will($this->throwException($exception));
124 $this->loggerMock->expects($this->once())
126 ->with($this->equalTo($exception));
127 $this->assertFalse($this->notifier->notify($this->shipment));
$historyCollectionFactory