@@ -448,14 +448,14 @@ public function testModifyData()
448
448
449
449
/**
450
450
* @param int $productId
451
- * @param bool $productRequired
451
+ * @param array $attributeData
452
452
* @param string $attrValue
453
453
* @param array $expected
454
454
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists
455
455
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
456
456
* @dataProvider setupAttributeMetaDataProvider
457
457
*/
458
- public function testSetupAttributeMetaDefaultAttribute ($ productId , $ productRequired , $ attrValue , $ expected )
458
+ public function testSetupAttributeMetaDefaultAttribute ($ productId , array $ attributeData , $ attrValue , $ expected )
459
459
{
460
460
$ configPath = 'arguments/data/config ' ;
461
461
$ groupCode = 'product-details ' ;
@@ -465,9 +465,7 @@ public function testSetupAttributeMetaDefaultAttribute($productId, $productRequi
465
465
->method ('getId ' )
466
466
->willReturn ($ productId );
467
467
468
- $ this ->productAttributeMock ->expects ($ this ->any ())
469
- ->method ('getIsRequired ' )
470
- ->willReturn ($ productRequired );
468
+ $ this ->initDataMock ($ this ->productAttributeMock , $ attributeData );
471
469
472
470
$ this ->productAttributeMock ->expects ($ this ->any ())
473
471
->method ('getDefaultValue ' )
@@ -529,7 +527,10 @@ public function setupAttributeMetaDataProvider()
529
527
return [
530
528
'default_null_prod_not_new_and_required ' => [
531
529
'productId ' => 1 ,
532
- 'productRequired ' => true ,
530
+ 'attributeData ' => [
531
+ 'is_required ' => true ,
532
+ 'default_frontend_label ' => 'text ' ,
533
+ ],
533
534
'attrValue ' => 'val ' ,
534
535
'expected ' => [
535
536
'dataType ' => null ,
@@ -538,7 +539,7 @@ public function setupAttributeMetaDataProvider()
538
539
'required ' => true ,
539
540
'notice ' => null ,
540
541
'default ' => null ,
541
- 'label ' => null ,
542
+ 'label ' => __ ( ' text ' ) ,
542
543
'code ' => 'code ' ,
543
544
'source ' => 'product-details ' ,
544
545
'scopeLabel ' => '' ,
@@ -548,7 +549,10 @@ public function setupAttributeMetaDataProvider()
548
549
],
549
550
'default_null_prod_not_new_and_not_required ' => [
550
551
'productId ' => 1 ,
551
- 'productRequired ' => false ,
552
+ 'attributeData ' => [
553
+ 'productRequired ' => false ,
554
+ 'default_frontend_label ' => 'text ' ,
555
+ ],
552
556
'attrValue ' => 'val ' ,
553
557
'expected ' => [
554
558
'dataType ' => null ,
@@ -557,7 +561,7 @@ public function setupAttributeMetaDataProvider()
557
561
'required ' => false ,
558
562
'notice ' => null ,
559
563
'default ' => null ,
560
- 'label ' => null ,
564
+ 'label ' => __ ( ' text ' ) ,
561
565
'code ' => 'code ' ,
562
566
'source ' => 'product-details ' ,
563
567
'scopeLabel ' => '' ,
@@ -567,7 +571,9 @@ public function setupAttributeMetaDataProvider()
567
571
],
568
572
'default_null_prod_new_and_not_required ' => [
569
573
'productId ' => null ,
570
- 'productRequired ' => false ,
574
+ 'attributeData ' => [
575
+ 'productRequired ' => false ,
576
+ ],
571
577
'attrValue ' => null ,
572
578
'expected ' => [
573
579
'dataType ' => null ,
@@ -576,7 +582,7 @@ public function setupAttributeMetaDataProvider()
576
582
'required ' => false ,
577
583
'notice ' => null ,
578
584
'default ' => 'required_value ' ,
579
- 'label ' => null ,
585
+ 'label ' => __ ( null ) ,
580
586
'code ' => 'code ' ,
581
587
'source ' => 'product-details ' ,
582
588
'scopeLabel ' => '' ,
@@ -586,7 +592,9 @@ public function setupAttributeMetaDataProvider()
586
592
],
587
593
'default_null_prod_new_and_required ' => [
588
594
'productId ' => null ,
589
- 'productRequired ' => false ,
595
+ 'attributeData ' => [
596
+ 'productRequired ' => false ,
597
+ ],
590
598
'attrValue ' => null ,
591
599
'expected ' => [
592
600
'dataType ' => null ,
@@ -595,7 +603,7 @@ public function setupAttributeMetaDataProvider()
595
603
'required ' => false ,
596
604
'notice ' => null ,
597
605
'default ' => 'required_value ' ,
598
- 'label ' => null ,
606
+ 'label ' => __ ( null ) ,
599
607
'code ' => 'code ' ,
600
608
'source ' => 'product-details ' ,
601
609
'scopeLabel ' => '' ,
@@ -605,4 +613,16 @@ public function setupAttributeMetaDataProvider()
605
613
]
606
614
];
607
615
}
616
+
617
+ /**
618
+ * @param \PHPUnit_Framework_MockObject_MockObject $mock
619
+ * @param array $data
620
+ */
621
+ private function initDataMock (\PHPUnit_Framework_MockObject_MockObject $ mock , array $ data )
622
+ {
623
+ foreach ($ data as $ key => $ value ) {
624
+ $ mock ->method ('get ' . implode (explode ('_ ' , ucwords ($ key , "_ " ))))
625
+ ->willReturn ($ value );
626
+ }
627
+ }
608
628
}
0 commit comments