9
9
use Magento \Framework \App \ResourceConnection ;
10
10
use Magento \Sales \Api \Data \OrderStatusHistoryInterface ;
11
11
use Magento \Sales \Api \OrderRepositoryInterface ;
12
+ use Magento \Sales \Model \Order ;
12
13
use Magento \Signifyd \Api \CaseRepositoryInterface ;
13
14
use Magento \Signifyd \Api \Data \CaseInterface ;
14
15
use Magento \Signifyd \Model \MessageGenerators \GeneratorFactory ;
@@ -47,6 +48,7 @@ protected function setUp()
47
48
48
49
/**
49
50
* Checks case updating flow and messages in order comments history.
51
+ * Also checks that order is unholded when case guarantee disposition is APPROVED.
50
52
*
51
53
* @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
52
54
* @magentoDataFixture Magento/Signifyd/_files/case.php
@@ -97,6 +99,7 @@ public function testUpdate()
97
99
/** @var OrderRepositoryInterface $orderRepository */
98
100
$ orderRepository = $ this ->objectManager ->get (OrderRepositoryInterface::class);
99
101
$ order = $ orderRepository ->get ($ caseEntity ->getOrderId ());
102
+ static ::assertEquals (Order::STATE_PROCESSING , $ order ->getState ());
100
103
$ histories = $ order ->getStatusHistories ();
101
104
static ::assertNotEmpty ($ histories );
102
105
@@ -106,6 +109,63 @@ public function testUpdate()
106
109
static ::assertEquals ("Signifyd Case $ caseId has been created for order. " , $ caseCreationComment ->getComment ());
107
110
}
108
111
112
+ /**
113
+ * Checks that order is holded when case guarantee disposition is DECLINED.
114
+ *
115
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
116
+ * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
117
+ */
118
+ public function testOrderStateAfterDeclinedGuaranteeDisposition ()
119
+ {
120
+ $ caseId = 123 ;
121
+ $ data = [
122
+ 'caseId ' => $ caseId ,
123
+ 'orderId ' => '100000001 ' ,
124
+ 'guaranteeDisposition ' => CaseInterface::GUARANTEE_DECLINED
125
+ ];
126
+
127
+ /** @var CaseRepositoryInterface $caseRepository */
128
+ $ caseRepository = $ this ->objectManager ->get (CaseRepositoryInterface::class);
129
+ $ caseEntity = $ caseRepository ->getByCaseId ($ caseId );
130
+
131
+ $ this ->service ->update ($ caseEntity , $ data );
132
+
133
+ /** @var OrderRepositoryInterface $orderRepository */
134
+ $ orderRepository = $ this ->objectManager ->get (OrderRepositoryInterface::class);
135
+ $ order = $ orderRepository ->get ($ caseEntity ->getOrderId ());
136
+
137
+ static ::assertEquals (Order::STATE_HOLDED , $ order ->getState ());
138
+ }
139
+
140
+ /**
141
+ * Checks that order doesn't become holded
142
+ * when previous case guarantee disposition was DECLINED
143
+ * and webhook without guarantee disposition was received.
144
+ *
145
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
146
+ * @magentoDataFixture Magento/Signifyd/_files/declined_case.php
147
+ */
148
+ public function testOrderStateAfterWebhookWithoutGuaranteeDisposition ()
149
+ {
150
+ $ caseId = 123 ;
151
+ $ data = [
152
+ 'caseId ' => $ caseId ,
153
+ 'orderId ' => '100000001 '
154
+ ];
155
+
156
+ /** @var CaseRepositoryInterface $caseRepository */
157
+ $ caseRepository = $ this ->objectManager ->get (CaseRepositoryInterface::class);
158
+ $ caseEntity = $ caseRepository ->getByCaseId ($ caseId );
159
+
160
+ $ this ->service ->update ($ caseEntity , $ data );
161
+
162
+ /** @var OrderRepositoryInterface $orderRepository */
163
+ $ orderRepository = $ this ->objectManager ->get (OrderRepositoryInterface::class);
164
+ $ order = $ orderRepository ->get ($ caseEntity ->getOrderId ());
165
+
166
+ static ::assertEquals (Order::STATE_PROCESSING , $ order ->getState ());
167
+ }
168
+
109
169
/**
110
170
* Returns value of signifyd_guarantee_status column from sales order grid
111
171
*
0 commit comments