5
5
*/
6
6
namespace Magento \Signifyd \Model \CaseServices ;
7
7
8
- use Magento \Framework \Api \FilterBuilder ;
9
8
use Magento \Framework \Api \SearchCriteriaBuilder ;
10
9
use Magento \Framework \App \ObjectManager ;
11
10
use Magento \Sales \Api \Data \OrderInterface ;
12
11
use Magento \Sales \Api \Data \OrderStatusHistoryInterface ;
13
12
use Magento \Sales \Api \OrderRepositoryInterface ;
14
13
use Magento \Sales \Model \Order ;
14
+ use Magento \Sales \Model \ResourceModel \Order \Grid \Collection ;
15
15
use Magento \Signifyd \Api \CaseRepositoryInterface ;
16
16
use Magento \Signifyd \Model \SignifydGateway \ApiCallException ;
17
17
use Magento \Signifyd \Model \SignifydGateway \ApiClient ;
@@ -98,16 +98,16 @@ public function testCreateForOrderWithEmptyResponse()
98
98
$ order = $ this ->getOrder ();
99
99
$ exceptionMessage = 'Response is not valid JSON: Decoding failed: Syntax error ' ;
100
100
101
- $ this ->requestBuilder ->expects (static ::once ())
101
+ $ this ->requestBuilder ->expects (self ::once ())
102
102
->method ('doRequest ' )
103
103
->willThrowException (new ApiCallException ($ exceptionMessage ));
104
104
105
- $ this ->logger ->expects (static ::once ())
105
+ $ this ->logger ->expects (self ::once ())
106
106
->method ('error ' )
107
107
->with ($ exceptionMessage );
108
108
109
109
$ result = $ this ->service ->createForOrder ($ order ->getEntityId ());
110
- static ::assertTrue ($ result );
110
+ self ::assertTrue ($ result );
111
111
}
112
112
113
113
/**
@@ -124,16 +124,16 @@ public function testCreateForOrderWithBadResponse()
124
124
];
125
125
$ exceptionMessage = 'Bad Request - The request could not be parsed. Response: ' . json_encode ($ responseData );
126
126
127
- $ this ->requestBuilder ->expects (static ::once ())
127
+ $ this ->requestBuilder ->expects (self ::once ())
128
128
->method ('doRequest ' )
129
129
->willThrowException (new ApiCallException ($ exceptionMessage ));
130
130
131
- $ this ->logger ->expects (static ::once ())
131
+ $ this ->logger ->expects (self ::once ())
132
132
->method ('error ' )
133
133
->with ($ exceptionMessage );
134
134
135
135
$ result = $ this ->service ->createForOrder ($ order ->getEntityId ());
136
- static ::assertTrue ($ result );
136
+ self ::assertTrue ($ result );
137
137
}
138
138
139
139
/**
@@ -144,16 +144,16 @@ public function testCreateOrderWithEmptyInvestigationId()
144
144
{
145
145
$ order = $ this ->getOrder ();
146
146
147
- $ this ->requestBuilder ->expects (static ::once ())
147
+ $ this ->requestBuilder ->expects (self ::once ())
148
148
->method ('doRequest ' )
149
149
->willReturn ([]);
150
150
151
- $ this ->logger ->expects (static ::once ())
151
+ $ this ->logger ->expects (self ::once ())
152
152
->method ('error ' )
153
153
->with ('Expected field "investigationId" missed. ' );
154
154
155
155
$ result = $ this ->service ->createForOrder ($ order ->getEntityId ());
156
- static ::assertTrue ($ result );
156
+ self ::assertTrue ($ result );
157
157
}
158
158
159
159
/**
@@ -164,24 +164,24 @@ public function testCreateForOrder()
164
164
{
165
165
$ order = $ this ->getOrder ();
166
166
167
- $ this ->requestBuilder ->expects (static ::once ())
167
+ $ this ->requestBuilder ->expects (self ::once ())
168
168
->method ('doRequest ' )
169
169
->willReturn (['investigationId ' => 123123 ]);
170
170
171
- $ this ->logger ->expects (static ::never ())
171
+ $ this ->logger ->expects (self ::never ())
172
172
->method ('error ' );
173
173
174
174
$ result = $ this ->service ->createForOrder ($ order ->getEntityId ());
175
- static ::assertTrue ($ result );
175
+ self ::assertTrue ($ result );
176
176
177
177
/** @var CaseRepositoryInterface $caseRepository */
178
178
$ caseRepository = $ this ->objectManager ->get (CaseRepositoryInterface::class);
179
179
$ caseEntity = $ caseRepository ->getByCaseId (123123 );
180
180
$ gridGuarantyStatus = $ this ->getOrderGridGuarantyStatus ($ caseEntity ->getOrderId ());
181
181
182
- static ::assertNotEmpty ($ caseEntity );
183
- static ::assertEquals ($ order ->getEntityId (), $ caseEntity ->getOrderId ());
184
- static ::assertEquals (
182
+ self ::assertNotEmpty ($ caseEntity );
183
+ self ::assertEquals ($ order ->getEntityId (), $ caseEntity ->getOrderId ());
184
+ self ::assertEquals (
185
185
$ gridGuarantyStatus ,
186
186
$ caseEntity ->getGuaranteeDisposition (),
187
187
'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status '
@@ -190,15 +190,15 @@ public function testCreateForOrder()
190
190
/** @var OrderRepositoryInterface $orderRepository */
191
191
$ orderRepository = $ this ->objectManager ->get (OrderRepositoryInterface::class);
192
192
$ order = $ orderRepository ->get ($ caseEntity ->getOrderId ());
193
- static ::assertEquals (Order::STATE_HOLDED , $ order ->getState ());
193
+ self ::assertEquals (Order::STATE_HOLDED , $ order ->getState ());
194
194
195
195
$ histories = $ order ->getStatusHistories ();
196
- static ::assertNotEmpty ($ histories );
196
+ self ::assertNotEmpty ($ histories );
197
197
198
198
/** @var OrderStatusHistoryInterface $orderHoldComment */
199
199
$ orderHoldComment = array_pop ($ histories );
200
- static ::assertInstanceOf (OrderStatusHistoryInterface::class, $ orderHoldComment );
201
- static ::assertEquals ("Awaiting the Signifyd guarantee disposition. " , $ orderHoldComment ->getComment ());
200
+ self ::assertInstanceOf (OrderStatusHistoryInterface::class, $ orderHoldComment );
201
+ self ::assertEquals ("Awaiting the Signifyd guarantee disposition. " , $ orderHoldComment ->getComment ());
202
202
}
203
203
204
204
/**
@@ -209,17 +209,10 @@ public function testCreateForOrder()
209
209
private function getOrder ()
210
210
{
211
211
if ($ this ->order === null ) {
212
- /** @var FilterBuilder $filterBuilder */
213
- $ filterBuilder = $ this ->objectManager ->get (FilterBuilder::class);
214
- $ filters = [
215
- $ filterBuilder ->setField (OrderInterface::INCREMENT_ID )
216
- ->setValue ('100000001 ' )
217
- ->create ()
218
- ];
219
212
220
213
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
221
214
$ searchCriteriaBuilder = $ this ->objectManager ->get (SearchCriteriaBuilder::class);
222
- $ searchCriteria = $ searchCriteriaBuilder ->addFilters ( $ filters )
215
+ $ searchCriteria = $ searchCriteriaBuilder ->addFilter (OrderInterface:: INCREMENT_ID , ' 100000001 ' )
223
216
->create ();
224
217
225
218
$ orderRepository = $ this ->objectManager ->get (OrderRepositoryInterface::class);
@@ -240,10 +233,8 @@ private function getOrder()
240
233
*/
241
234
private function getOrderGridGuarantyStatus ($ orderEntityId )
242
235
{
243
- /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
244
- $ orderGridCollection = $ this ->objectManager ->get (
245
- \Magento \Sales \Model \ResourceModel \Order \Grid \Collection::class
246
- );
236
+ /** @var Collection $orderGridCollection */
237
+ $ orderGridCollection = $ this ->objectManager ->get (Collection::class);
247
238
248
239
$ items = $ orderGridCollection ->addFilter ($ orderGridCollection ->getIdFieldName (), $ orderEntityId )
249
240
->getItems ();
0 commit comments