@@ -231,7 +231,7 @@ public function testToArray(array $data, array $expected)
231
231
$ menuMock = $ this ->getMock (\Magento \Backend \Model \Menu::class, [], [], '' , false );
232
232
$ this ->_menuFactoryMock ->method ('create ' )->will ($ this ->returnValue ($ menuMock ));
233
233
$ menuMock ->method ('toArray ' )
234
- ->willReturn (isset ( $ data ['sub_menu ' ]) ? $ data [ ' sub_menu ' ] : null );
234
+ ->willReturn ($ data ['sub_menu ' ]);
235
235
236
236
$ model = $ this ->objectManager ->getObject (
237
237
\Magento \Backend \Model \Menu \Item::class,
@@ -248,119 +248,12 @@ public function testToArray(array $data, array $expected)
248
248
$ this ->assertEquals ($ expected , $ model ->toArray ());
249
249
}
250
250
251
+ /**
252
+ * @return array
253
+ */
251
254
public function toArrayDataProvider ()
252
255
{
253
- return [
254
- 'No submenu ' => [
255
- [
256
- 'id ' => 'item ' ,
257
- 'title ' => 'Item Title ' ,
258
- 'action ' => '/system/config ' ,
259
- 'resource ' => 'Magento_Config::config ' ,
260
- 'depends_on_module ' => 'Magento_Backend ' ,
261
- 'depends_on_config ' => 'system/config/isEnabled ' ,
262
- 'tooltip ' => 'Item tooltip ' ,
263
- ],
264
- [
265
- 'parent_id ' => null ,
266
- 'module_name ' => 'Magento_Backend ' ,
267
- 'sort_index ' => null ,
268
- 'depends_on_config ' => 'system/config/isEnabled ' ,
269
- 'id ' => 'item ' ,
270
- 'resource ' => 'Magento_Config::config ' ,
271
- 'path ' => '' ,
272
- 'action ' => '/system/config ' ,
273
- 'depends_on_module ' => 'Magento_Backend ' ,
274
- 'tooltip ' => 'Item tooltip ' ,
275
- 'title ' => 'Item Title ' ,
276
- 'sub_menu ' => null
277
- ]
278
- ],
279
- 'with submenu ' => [
280
- [
281
- 'parent_id ' => '1 ' ,
282
- 'module_name ' => 'Magento_Module1 ' ,
283
- 'sort_index ' => '50 ' ,
284
- 'depends_on_config ' => null ,
285
- 'id ' => '5 ' ,
286
- 'resource ' => null ,
287
- 'path ' => null ,
288
- 'action ' => null ,
289
- 'depends_on_module ' => null ,
290
- 'tooltip ' => null ,
291
- 'title ' => null ,
292
- 'sub_menu ' => [
293
- 'id ' => 'item ' ,
294
- 'title ' => 'Item Title ' ,
295
- 'action ' => '/system/config ' ,
296
- 'resource ' => 'Magento_Config::config ' ,
297
- 'depends_on_module ' => 'Magento_Backend ' ,
298
- 'depends_on_config ' => 'system/config/isEnabled ' ,
299
- 'tooltip ' => 'Item tooltip ' ,
300
- ],
301
- ],
302
- [
303
- 'parent_id ' => '1 ' ,
304
- 'module_name ' => 'Magento_Module1 ' ,
305
- 'sort_index ' => '50 ' ,
306
- 'depends_on_config ' => null ,
307
- 'id ' => '5 ' ,
308
- 'resource ' => null ,
309
- 'path ' => null ,
310
- 'action ' => null ,
311
- 'depends_on_module ' => null ,
312
- 'tooltip ' => '' ,
313
- 'title ' => null ,
314
- 'sub_menu ' => [
315
- 'id ' => 'item ' ,
316
- 'title ' => 'Item Title ' ,
317
- 'action ' => '/system/config ' ,
318
- 'resource ' => 'Magento_Config::config ' ,
319
- 'depends_on_module ' => 'Magento_Backend ' ,
320
- 'depends_on_config ' => 'system/config/isEnabled ' ,
321
- 'tooltip ' => 'Item tooltip ' ,
322
- ]
323
- ]
324
- ],
325
- 'small set of data ' => [
326
- [
327
- 'parent_id ' => '1 ' ,
328
- 'module_name ' => 'Magento_Module1 ' ,
329
- 'sort_index ' => '50 ' ,
330
- 'sub_menu ' => [
331
- 'id ' => 'item ' ,
332
- 'title ' => 'Item Title ' ,
333
- 'action ' => '/system/config ' ,
334
- 'resource ' => 'Magento_Config::config ' ,
335
- 'depends_on_module ' => 'Magento_Backend ' ,
336
- 'depends_on_config ' => 'system/config/isEnabled ' ,
337
- 'tooltip ' => 'Item tooltip ' ,
338
- ],
339
- ],
340
- [
341
- 'parent_id ' => '1 ' ,
342
- 'module_name ' => 'Magento_Module1 ' ,
343
- 'sort_index ' => '50 ' ,
344
- 'depends_on_config ' => null ,
345
- 'id ' => null ,
346
- 'resource ' => null ,
347
- 'path ' => '' ,
348
- 'action ' => null ,
349
- 'depends_on_module ' => null ,
350
- 'tooltip ' => '' ,
351
- 'title ' => null ,
352
- 'sub_menu ' => [
353
- 'id ' => 'item ' ,
354
- 'title ' => 'Item Title ' ,
355
- 'action ' => '/system/config ' ,
356
- 'resource ' => 'Magento_Config::config ' ,
357
- 'depends_on_module ' => 'Magento_Backend ' ,
358
- 'depends_on_config ' => 'system/config/isEnabled ' ,
359
- 'tooltip ' => 'Item tooltip ' ,
360
- ]
361
- ]
362
- ]
363
- ];
256
+ return include __DIR__ . '/../_files/menu_item_data.php ' ;
364
257
}
365
258
366
259
/**
@@ -375,7 +268,7 @@ public function testPopulateFromArray(
375
268
array $ expected
376
269
) {
377
270
$ menuMock = $ this ->getMock (\Magento \Backend \Model \Menu::class, [], [], '' , false );
378
- $ this ->_menuFactoryMock ->method ('create ' )->will ( $ this -> returnValue ( $ menuMock) );
271
+ $ this ->_menuFactoryMock ->method ('create ' )->willReturn ( $ menuMock );
379
272
$ menuMock ->method ('toArray ' )
380
273
->willReturn (['submenuArray ' ]);
381
274
@@ -395,134 +288,11 @@ public function testPopulateFromArray(
395
288
$ this ->assertEquals ($ expected , $ model ->toArray ());
396
289
}
397
290
291
+ /**
292
+ * @return array
293
+ */
398
294
public function populateFromArrayDataProvider ()
399
295
{
400
- return [
401
- 'default data to constructor ' => [
402
- [],
403
- [
404
- 'id ' => 'item ' ,
405
- 'title ' => 'Item Title ' ,
406
- 'action ' => '/system/config ' ,
407
- 'resource ' => 'Magento_Config::config ' ,
408
- 'depends_on_module ' => 'Magento_Backend ' ,
409
- 'depends_on_config ' => 'system/config/isEnabled ' ,
410
- 'tooltip ' => 'Item tooltip ' ,
411
- ],
412
- [
413
- 'parent_id ' => null ,
414
- 'module_name ' => 'Magento_Backend ' ,
415
- 'sort_index ' => null ,
416
- 'depends_on_config ' => 'system/config/isEnabled ' ,
417
- 'id ' => 'item ' ,
418
- 'resource ' => 'Magento_Config::config ' ,
419
- 'path ' => '' ,
420
- 'action ' => '/system/config ' ,
421
- 'depends_on_module ' => 'Magento_Backend ' ,
422
- 'tooltip ' => 'Item tooltip ' ,
423
- 'title ' => 'Item Title ' ,
424
- 'sub_menu ' => null
425
- ],
426
- ],
427
- 'data without submenu to constructor ' => [
428
- [
429
- 'id ' => 'item ' ,
430
- 'title ' => 'Item Title ' ,
431
- 'action ' => '/system/config ' ,
432
- 'resource ' => 'Magento_Config::config ' ,
433
- 'depends_on_module ' => 'Magento_Backend ' ,
434
- 'depends_on_config ' => 'system/config/isEnabled ' ,
435
- 'tooltip ' => 'Item tooltip ' ,
436
- ],
437
- [
438
- 'parent_id ' => '1 ' ,
439
- 'module_name ' => 'Magento_Module1 ' ,
440
- 'sort_index ' => '50 ' ,
441
- 'depends_on_config ' => null ,
442
- 'id ' => '5 ' ,
443
- 'resource ' => null ,
444
- 'path ' => null ,
445
- 'action ' => null ,
446
- 'depends_on_module ' => null ,
447
- 'tooltip ' => null ,
448
- 'title ' => null ,
449
- 'sub_menu ' => [
450
- 'id ' => 'item ' ,
451
- 'title ' => 'Item Title ' ,
452
- 'action ' => '/system/config ' ,
453
- 'resource ' => 'Magento_Config::config ' ,
454
- 'depends_on_module ' => 'Magento_Backend ' ,
455
- 'depends_on_config ' => 'system/config/isEnabled ' ,
456
- 'tooltip ' => 'Item tooltip ' ,
457
- ],
458
- ],
459
- [
460
- 'parent_id ' => '1 ' ,
461
- 'module_name ' => 'Magento_Module1 ' ,
462
- 'sort_index ' => '50 ' ,
463
- 'depends_on_config ' => null ,
464
- 'id ' => '5 ' ,
465
- 'resource ' => null ,
466
- 'path ' => '' ,
467
- 'action ' => null ,
468
- 'depends_on_module ' => null ,
469
- 'tooltip ' => '' ,
470
- 'title ' => null ,
471
- 'sub_menu ' => ['submenuArray ' ]
472
- ],
473
- ],
474
- 'data with submenu to constructor ' => [
475
- [
476
- 'parent_id ' => '1 ' ,
477
- 'module_name ' => 'Magento_Module1 ' ,
478
- 'sort_index ' => '50 ' ,
479
- 'depends_on_config ' => null ,
480
- 'id ' => '5 ' ,
481
- 'resource ' => null ,
482
- 'path ' => null ,
483
- 'action ' => null ,
484
- 'depends_on_module ' => null ,
485
- 'tooltip ' => null ,
486
- 'title ' => null ,
487
- 'sub_menu ' => [
488
- 'id ' => 'item ' ,
489
- 'title ' => 'Item Title ' ,
490
- 'action ' => '/system/config ' ,
491
- 'resource ' => 'Magento_Config::config ' ,
492
- 'depends_on_module ' => 'Magento_Backend ' ,
493
- 'depends_on_config ' => 'system/config/isEnabled ' ,
494
- 'tooltip ' => 'Item tooltip ' ,
495
- ],
496
- ],
497
- [
498
- 'parent_id ' => '1 ' ,
499
- 'module_name ' => 'Magento_Module1 ' ,
500
- 'sort_index ' => '50 ' ,
501
- 'sub_menu ' => [
502
- 'id ' => 'item ' ,
503
- 'title ' => 'Item Title ' ,
504
- 'action ' => '/system/config ' ,
505
- 'resource ' => 'Magento_Config::config ' ,
506
- 'depends_on_module ' => 'Magento_Backend ' ,
507
- 'depends_on_config ' => 'system/config/isEnabled ' ,
508
- 'tooltip ' => 'Item tooltip ' ,
509
- ],
510
- ],
511
- [
512
- 'parent_id ' => '1 ' ,
513
- 'module_name ' => 'Magento_Module1 ' ,
514
- 'sort_index ' => '50 ' ,
515
- 'depends_on_config ' => null ,
516
- 'id ' => null ,
517
- 'resource ' => null ,
518
- 'path ' => '' ,
519
- 'action ' => null ,
520
- 'depends_on_module ' => null ,
521
- 'tooltip ' => '' ,
522
- 'title ' => null ,
523
- 'sub_menu ' => ['submenuArray ' ]
524
- ],
525
- ]
526
- ];
296
+ return include __DIR__ . '/../_files/menu_item_constructor_data.php ' ;
527
297
}
528
298
}
0 commit comments