Skip to content

Commit 8dec1a2

Browse files
committed
MAGETWO-71707: Merge release branch into 2.1-develop
-- fix unit tests
1 parent bbaebf7 commit 8dec1a2

File tree

1 file changed

+33
-13
lines changed
  • app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier

1 file changed

+33
-13
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,14 @@ public function testModifyData()
448448

449449
/**
450450
* @param int $productId
451-
* @param bool $productRequired
451+
* @param array $attributeData
452452
* @param string $attrValue
453453
* @param array $expected
454454
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists
455455
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
456456
* @dataProvider setupAttributeMetaDataProvider
457457
*/
458-
public function testSetupAttributeMetaDefaultAttribute($productId, $productRequired, $attrValue, $expected)
458+
public function testSetupAttributeMetaDefaultAttribute($productId, array $attributeData, $attrValue, $expected)
459459
{
460460
$configPath = 'arguments/data/config';
461461
$groupCode = 'product-details';
@@ -465,9 +465,7 @@ public function testSetupAttributeMetaDefaultAttribute($productId, $productRequi
465465
->method('getId')
466466
->willReturn($productId);
467467

468-
$this->productAttributeMock->expects($this->any())
469-
->method('getIsRequired')
470-
->willReturn($productRequired);
468+
$this->initDataMock($this->productAttributeMock, $attributeData);
471469

472470
$this->productAttributeMock->expects($this->any())
473471
->method('getDefaultValue')
@@ -529,7 +527,10 @@ public function setupAttributeMetaDataProvider()
529527
return [
530528
'default_null_prod_not_new_and_required' => [
531529
'productId' => 1,
532-
'productRequired' => true,
530+
'attributeData' => [
531+
'is_required' => true,
532+
'default_frontend_label' => 'text',
533+
],
533534
'attrValue' => 'val',
534535
'expected' => [
535536
'dataType' => null,
@@ -538,7 +539,7 @@ public function setupAttributeMetaDataProvider()
538539
'required' => true,
539540
'notice' => null,
540541
'default' => null,
541-
'label' => null,
542+
'label' => __('text'),
542543
'code' => 'code',
543544
'source' => 'product-details',
544545
'scopeLabel' => '',
@@ -548,7 +549,10 @@ public function setupAttributeMetaDataProvider()
548549
],
549550
'default_null_prod_not_new_and_not_required' => [
550551
'productId' => 1,
551-
'productRequired' => false,
552+
'attributeData' => [
553+
'productRequired' => false,
554+
'default_frontend_label' => 'text',
555+
],
552556
'attrValue' => 'val',
553557
'expected' => [
554558
'dataType' => null,
@@ -557,7 +561,7 @@ public function setupAttributeMetaDataProvider()
557561
'required' => false,
558562
'notice' => null,
559563
'default' => null,
560-
'label' => null,
564+
'label' => __('text'),
561565
'code' => 'code',
562566
'source' => 'product-details',
563567
'scopeLabel' => '',
@@ -567,7 +571,9 @@ public function setupAttributeMetaDataProvider()
567571
],
568572
'default_null_prod_new_and_not_required' => [
569573
'productId' => null,
570-
'productRequired' => false,
574+
'attributeData' => [
575+
'productRequired' => false,
576+
],
571577
'attrValue' => null,
572578
'expected' => [
573579
'dataType' => null,
@@ -576,7 +582,7 @@ public function setupAttributeMetaDataProvider()
576582
'required' => false,
577583
'notice' => null,
578584
'default' => 'required_value',
579-
'label' => null,
585+
'label' => __(null),
580586
'code' => 'code',
581587
'source' => 'product-details',
582588
'scopeLabel' => '',
@@ -586,7 +592,9 @@ public function setupAttributeMetaDataProvider()
586592
],
587593
'default_null_prod_new_and_required' => [
588594
'productId' => null,
589-
'productRequired' => false,
595+
'attributeData' => [
596+
'productRequired' => false,
597+
],
590598
'attrValue' => null,
591599
'expected' => [
592600
'dataType' => null,
@@ -595,7 +603,7 @@ public function setupAttributeMetaDataProvider()
595603
'required' => false,
596604
'notice' => null,
597605
'default' => 'required_value',
598-
'label' => null,
606+
'label' => __(null),
599607
'code' => 'code',
600608
'source' => 'product-details',
601609
'scopeLabel' => '',
@@ -605,4 +613,16 @@ public function setupAttributeMetaDataProvider()
605613
]
606614
];
607615
}
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+
}
608628
}

0 commit comments

Comments
 (0)