10 use Magento\Sales\Model\OrderFactory;
14 use PHPUnit_Framework_MockObject_MockObject as MockObject;
21 private static $orderId = 123;
26 private $orderFactory;
31 private $orderManagement;
36 private $commentsHistoryUpdater;
51 private $orderStateService;
58 $this->orderManagement = $this->getMockBuilder(OrderManagementInterface::class)
59 ->getMockForAbstractClass();
61 $this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class)
62 ->disableOriginalConstructor()
65 $this->orderFactory = $this->getMockBuilder(OrderFactory::class)
66 ->setMethods([
'create'])
67 ->disableOriginalConstructor()
70 $this->order = $this->getMockBuilder(Order::class)
71 ->disableOriginalConstructor()
73 $this->order->expects($this->once())
77 $this->orderFactory->expects($this->once())
79 ->willReturn($this->order);
81 $this->caseEntity = $this->getMockBuilder(CaseInterface::class)
82 ->disableOriginalConstructor()
83 ->getMockForAbstractClass();
84 $this->caseEntity->expects($this->once())
85 ->method(
'getOrderId')
86 ->willReturn(self::$orderId);
90 $this->orderManagement,
91 $this->commentsHistoryUpdater
105 $this->caseEntity->expects($this->once())
106 ->method(
'getGuaranteeDisposition')
108 $this->order->expects($this->any())
110 ->willReturn($canHold);
111 $this->orderManagement->expects($this->any())
114 $this->commentsHistoryUpdater->expects($this->exactly($addCommentCall))
115 ->method(
'addComment')
118 __(
'Awaiting the Signifyd guarantee disposition.'),
122 $this->orderStateService->updateByCase($this->caseEntity);
131 [
'canHold' =>
true,
'hold' =>
true,
'addCommentCall' => 1],
132 [
'canHold' =>
false,
'hold' =>
true,
'addCommentCall' => 0],
133 [
'canHold' =>
true,
'hold' =>
false,
'addCommentCall' => 0],
146 $this->caseEntity->expects($this->once())
147 ->method(
'getGuaranteeDisposition')
149 $this->order->expects($this->any())
150 ->method(
'canUnhold')
151 ->willReturn($canUnhold);
152 $this->orderManagement->expects($this->exactly($unholdCall))
154 $this->commentsHistoryUpdater->expects($this->never())
155 ->method(
'addComment');
157 $this->orderStateService->updateByCase($this->caseEntity);
166 [
'canUnhold' =>
true,
'unholdCall' => 1],
167 [
'canUnhold' =>
false,
'unholdCall' => 0]
180 $this->caseEntity->expects($this->once())
181 ->method(
'getGuaranteeDisposition')
183 $this->order->expects($this->any())
185 ->willReturn($canHold);
186 $this->orderManagement->expects($this->exactly($holdCall))
188 $this->commentsHistoryUpdater->expects($this->never())
189 ->method(
'addComment');
191 $this->orderStateService->updateByCase($this->caseEntity);
200 [
'canHold' =>
true,
'holdCall' => 1],
201 [
'canHold' =>
false,
'holdCall' => 0]
updateByCaseWithGuaranteeApprovedDataProvider()
testUpdateByCaseWithGuaranteeDeclined($canHold, $holdCall)
updateByCaseWithGuaranteeDeclinedDataProvider()
testUpdateByCaseWithGuaranteeApproved($canUnhold, $unholdCall)
testUpdateByCaseWithGuaranteePending($canHold, $hold, $addCommentCall)
updateByCaseWithGuaranteePendingDataProvider()