6
6
7
7
namespace Magento \Payment \Test \Unit \Helper ;
8
8
9
- use \Magento \Payment \Helper \Data ;
10
-
11
9
use Magento \Framework \TestFramework \Unit \Matcher \MethodInvokedAtIndex ;
10
+ use Magento \Payment \Helper \Data ;
11
+ use Magento \Store \Model \ScopeInterface ;
12
12
13
13
class DataTest extends \PHPUnit \Framework \TestCase
14
14
{
@@ -37,6 +37,9 @@ class DataTest extends \PHPUnit\Framework\TestCase
37
37
*/
38
38
private $ appEmulation ;
39
39
40
+ /**
41
+ * @inheritDoc
42
+ */
40
43
protected function setUp ()
41
44
{
42
45
$ objectManagerHelper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
@@ -57,6 +60,9 @@ protected function setUp()
57
60
$ this ->helper = $ objectManagerHelper ->getObject ($ className , $ arguments );
58
61
}
59
62
63
+ /**
64
+ * @return void
65
+ */
60
66
public function testGetMethodInstance ()
61
67
{
62
68
list ($ code , $ class , $ methodInstance ) = ['method_code ' , 'method_class ' , 'method_instance ' ];
@@ -170,6 +176,9 @@ public function testSortMethods(array $methodA, array $methodB)
170
176
);
171
177
}
172
178
179
+ /**
180
+ * @return void
181
+ */
173
182
public function testGetMethodFormBlock ()
174
183
{
175
184
list ($ blockType , $ methodCode ) = ['method_block_type ' , 'method_code ' ];
@@ -195,6 +204,9 @@ public function testGetMethodFormBlock()
195
204
$ this ->assertSame ($ blockMock , $ this ->helper ->getMethodFormBlock ($ methodMock , $ layoutMock ));
196
205
}
197
206
207
+ /**
208
+ * @return void`
209
+ */
198
210
public function testGetInfoBlock ()
199
211
{
200
212
$ blockType = 'method_block_type ' ;
@@ -220,6 +232,9 @@ public function testGetInfoBlock()
220
232
$ this ->assertSame ($ blockMock , $ this ->helper ->getInfoBlock ($ infoMock ));
221
233
}
222
234
235
+ /**
236
+ * @return void
237
+ */
223
238
public function testGetInfoBlockHtml ()
224
239
{
225
240
list ($ storeId , $ blockHtml , $ secureMode , $ blockType ) = [1 , 'HTML MARKUP ' , true , 'method_block_type ' ];
@@ -257,6 +272,23 @@ public function testGetInfoBlockHtml()
257
272
$ this ->assertEquals ($ blockHtml , $ this ->helper ->getInfoBlockHtml ($ infoMock , $ storeId ));
258
273
}
259
274
275
+ /**
276
+ * @return array
277
+ */
278
+ public function getSortMethodsDataProvider ()
279
+ {
280
+ return [
281
+ [
282
+ ['code ' => 'methodA ' , 'data ' => ['sort_order ' => 0 ]],
283
+ ['code ' => 'methodB ' , 'data ' => ['sort_order ' => 1 ]]
284
+ ],
285
+ [
286
+ ['code ' => 'methodA ' , 'data ' => ['sort_order ' => 2 ]],
287
+ ['code ' => 'methodB ' , 'data ' => ['sort_order ' => 1 ]],
288
+ ]
289
+ ];
290
+ }
291
+
260
292
/**
261
293
* @param bool $sorted
262
294
* @param bool $asLabelValue
@@ -288,17 +320,10 @@ public function testGetPaymentMethodList(
288
320
]
289
321
);
290
322
323
+ $ titlePath = sprintf ('%s/%s/title ' , Data::XML_PATH_PAYMENT_METHODS , $ paymentMethod ['code ' ]);
291
324
$ this ->scopeConfig ->method ('getValue ' )
292
- ->with (sprintf ('%s/%s/model ' , Data::XML_PATH_PAYMENT_METHODS , $ paymentMethod ['code ' ]))
293
- ->willReturn (\Magento \Payment \Model \Method \AbstractMethod::class);
294
-
295
- $ methodInstanceMock = $ this ->getMockBuilder (\Magento \Payment \Model \MethodInterface::class)
296
- ->getMockForAbstractClass ();
297
- $ methodInstanceMock ->method ('getConfigData ' )
298
- ->with ('title ' , null )
325
+ ->with ($ titlePath , ScopeInterface::SCOPE_STORE , null )
299
326
->willReturn ($ configTitle );
300
- $ this ->methodFactory ->method ('create ' )
301
- ->willReturn ($ methodInstanceMock );
302
327
303
328
$ this ->paymentConfig ->method ('getGroups ' )
304
329
->willReturn ($ groups );
@@ -307,23 +332,6 @@ public function testGetPaymentMethodList(
307
332
$ this ->assertEquals ($ expectedPaymentMethodList , $ paymentMethodList );
308
333
}
309
334
310
- /**
311
- * @return array
312
- */
313
- public function getSortMethodsDataProvider ()
314
- {
315
- return [
316
- [
317
- ['code ' => 'methodA ' , 'data ' => ['sort_order ' => 0 ]],
318
- ['code ' => 'methodB ' , 'data ' => ['sort_order ' => 1 ]]
319
- ],
320
- [
321
- ['code ' => 'methodA ' , 'data ' => ['sort_order ' => 2 ]],
322
- ['code ' => 'methodB ' , 'data ' => ['sort_order ' => 1 ]],
323
- ]
324
- ];
325
- }
326
-
327
335
/**
328
336
* @return array
329
337
*/
@@ -345,27 +353,12 @@ public function paymentMethodListDataProvider(): array
345
353
],
346
354
['payment_method ' => 'Config Payment Title ' ],
347
355
],
348
- 'Payment method with default title ' =>
349
- [
350
- true ,
351
- false ,
352
- false ,
353
- null ,
354
- [
355
- 'code ' => 'payment_method ' ,
356
- 'data ' => [
357
- 'active ' => 1 ,
358
- 'title ' => 'Payment Title ' ,
359
- ],
360
- ],
361
- ['payment_method ' => 'Payment Title ' ],
362
- ],
363
356
'Payment method as value => label ' =>
364
357
[
365
358
true ,
366
359
true ,
367
360
false ,
368
- null ,
361
+ ' Payment Title ' ,
369
362
[
370
363
'code ' => 'payment_method ' ,
371
364
'data ' => [
@@ -385,7 +378,7 @@ public function paymentMethodListDataProvider(): array
385
378
true ,
386
379
true ,
387
380
true ,
388
- null ,
381
+ ' Payment Title ' ,
389
382
[
390
383
'code ' => 'payment_method ' ,
391
384
'data ' => [
0 commit comments