@@ -33,7 +33,7 @@ public function testReSetPayment()
33
33
34
34
$ serviceInfo = [
35
35
'rest ' => [
36
- 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-methods ' ,
36
+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-method ' ,
37
37
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
38
38
],
39
39
'soap ' => [
@@ -70,7 +70,7 @@ public function testSetPaymentWithVirtualProduct()
70
70
71
71
$ serviceInfo = [
72
72
'rest ' => [
73
- 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-methods ' ,
73
+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-method ' ,
74
74
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
75
75
],
76
76
'soap ' => [
@@ -106,7 +106,7 @@ public function testSetPaymentWithSimpleProduct()
106
106
107
107
$ serviceInfo = [
108
108
'rest ' => [
109
- 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-methods ' ,
109
+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-method ' ,
110
110
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
111
111
],
112
112
'soap ' => [
@@ -145,7 +145,7 @@ public function testSetPaymentWithVirtualProductWithoutAddress()
145
145
146
146
$ serviceInfo = [
147
147
'rest ' => [
148
- 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-methods ' ,
148
+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-method ' ,
149
149
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
150
150
],
151
151
'soap ' => [
@@ -183,7 +183,7 @@ public function testSetPaymentWithSimpleProductWithoutAddress()
183
183
184
184
$ serviceInfo = [
185
185
'rest ' => [
186
- 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-methods ' ,
186
+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-method ' ,
187
187
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
188
188
],
189
189
'soap ' => [
@@ -253,7 +253,7 @@ public function testGet()
253
253
254
254
$ serviceInfo = [
255
255
'rest ' => [
256
- 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-methods ' ,
256
+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/selected-payment-method ' ,
257
257
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_GET ,
258
258
],
259
259
'soap ' => [
@@ -266,21 +266,10 @@ public function testGet()
266
266
$ requestData = ["cartId " => $ cartId ];
267
267
$ requestResponse = $ this ->_webApiCall ($ serviceInfo , $ requestData );
268
268
269
- $ this ->assertArrayHasKey ('method ' , $ requestResponse );
270
- $ this ->assertArrayHasKey ('po_number ' , $ requestResponse );
271
- $ this ->assertArrayHasKey ('cc_owner ' , $ requestResponse );
272
- $ this ->assertArrayHasKey ('cc_type ' , $ requestResponse );
273
- $ this ->assertArrayHasKey ('cc_exp_year ' , $ requestResponse );
274
- $ this ->assertArrayHasKey ('cc_exp_month ' , $ requestResponse );
275
- $ this ->assertArrayHasKey ('additional_data ' , $ requestResponse );
276
-
277
- $ this ->assertNotNull ($ requestResponse ['method ' ]);
278
- $ this ->assertNotNull ($ requestResponse ['po_number ' ]);
279
- $ this ->assertNotNull ($ requestResponse ['cc_owner ' ]);
280
- $ this ->assertNotNull ($ requestResponse ['cc_type ' ]);
281
- $ this ->assertNotNull ($ requestResponse ['cc_exp_year ' ]);
282
- $ this ->assertNotNull ($ requestResponse ['cc_exp_month ' ]);
283
- $ this ->assertNotNull ($ requestResponse ['additional_data ' ]);
269
+ foreach ($ this ->getPaymentMethodFieldsForAssert () as $ field ) {
270
+ $ this ->assertArrayHasKey ($ field , $ requestResponse );
271
+ $ this ->assertNotNull ($ requestResponse [$ field ]);
272
+ }
284
273
285
274
$ this ->assertEquals ('checkmo ' , $ requestResponse ['method ' ]);
286
275
}
@@ -292,7 +281,7 @@ public function testGetListMine()
292
281
{
293
282
$ this ->_markTestAsRestOnly ();
294
283
295
- /** @var \Magento\Quote\Model\Quote $quote */
284
+ /** @var \Magento\Quote\Model\Quote $quote */
296
285
$ quote = $ this ->objectManager ->create ('Magento\Quote\Model\Quote ' );
297
286
$ quote ->load ('test_order_1 ' , 'reserved_order_id ' );
298
287
@@ -329,30 +318,18 @@ public function testGetMine()
329
318
330
319
$ serviceInfo = [
331
320
'rest ' => [
332
- 'resourcePath ' => self ::RESOURCE_PATH . 'mine/selected-payment-methods ' ,
321
+ 'resourcePath ' => self ::RESOURCE_PATH . 'mine/selected-payment-method ' ,
333
322
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_GET ,
334
323
'token ' => $ this ->getCustomerToken ()
335
324
]
336
325
];
337
326
338
327
$ requestResponse = $ this ->_webApiCall ($ serviceInfo );
339
328
340
- $ this ->assertArrayHasKey ('method ' , $ requestResponse );
341
- $ this ->assertArrayHasKey ('po_number ' , $ requestResponse );
342
- $ this ->assertArrayHasKey ('cc_owner ' , $ requestResponse );
343
- $ this ->assertArrayHasKey ('cc_type ' , $ requestResponse );
344
- $ this ->assertArrayHasKey ('cc_exp_year ' , $ requestResponse );
345
- $ this ->assertArrayHasKey ('cc_exp_month ' , $ requestResponse );
346
- $ this ->assertArrayHasKey ('additional_data ' , $ requestResponse );
347
-
348
- $ this ->assertNotNull ($ requestResponse ['method ' ]);
349
- $ this ->assertNotNull ($ requestResponse ['po_number ' ]);
350
- $ this ->assertNotNull ($ requestResponse ['cc_owner ' ]);
351
- $ this ->assertNotNull ($ requestResponse ['cc_type ' ]);
352
- $ this ->assertNotNull ($ requestResponse ['cc_exp_year ' ]);
353
- $ this ->assertNotNull ($ requestResponse ['cc_exp_month ' ]);
354
- $ this ->assertNotNull ($ requestResponse ['additional_data ' ]);
355
-
329
+ foreach ($ this ->getPaymentMethodFieldsForAssert () as $ field ) {
330
+ $ this ->assertArrayHasKey ($ field , $ requestResponse );
331
+ $ this ->assertNotNull ($ requestResponse [$ field ]);
332
+ }
356
333
$ this ->assertEquals ('checkmo ' , $ requestResponse ['method ' ]);
357
334
}
358
335
@@ -363,13 +340,13 @@ public function testSetPaymentWithSimpleProductMine()
363
340
{
364
341
$ this ->_markTestAsRestOnly ();
365
342
366
- /** @var \Magento\Quote\Model\Quote $quote */
343
+ /** @var \Magento\Quote\Model\Quote $quote */
367
344
$ quote = $ this ->objectManager ->create ('\Magento\Quote\Model\Quote ' );
368
345
$ quote ->load ('test_order_1 ' , 'reserved_order_id ' );
369
346
370
347
$ serviceInfo = [
371
348
'rest ' => [
372
- 'resourcePath ' => self ::RESOURCE_PATH . 'mine/selected-payment-methods ' ,
349
+ 'resourcePath ' => self ::RESOURCE_PATH . 'mine/selected-payment-method ' ,
373
350
'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
374
351
'token ' => $ this ->getCustomerToken ()
375
352
]
@@ -389,6 +366,14 @@ public function testSetPaymentWithSimpleProductMine()
389
366
$ this ->assertNotNull ($ this ->_webApiCall ($ serviceInfo , $ requestData ));
390
367
}
391
368
369
+ /**
370
+ * @return array
371
+ */
372
+ protected function getPaymentMethodFieldsForAssert ()
373
+ {
374
+ return ['method ' , 'po_number ' , 'cc_owner ' , 'cc_type ' , 'cc_exp_year ' , 'cc_exp_month ' , 'additional_data ' ];
375
+ }
376
+
392
377
/**
393
378
* Get customer ID token
394
379
*
0 commit comments