Skip to content

Commit c2a34fe

Browse files
author
Yushkin, Dmytro
committed
MAGETWO-37956: It's unable to create Customer from Backend if there is custom Attribute
- fix for unit test
1 parent 907773f commit c2a34fe

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Eav\Model\Config;
99
use Magento\Eav\Model\Entity\Type;
10+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1011
use Magento\Ui\DataProvider\EavValidationRules;
1112
use Magento\Customer\Model\Customer\DataProvider;
1213
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
@@ -47,12 +48,15 @@ protected function setUp()
4748
$this->eavConfigMock = $this->getMockBuilder('Magento\Eav\Model\Config')
4849
->disableOriginalConstructor()
4950
->getMock();
50-
$this->customerCollectionFactoryMock = $this->getMockBuilder(
51-
'Magento\Customer\Model\Resource\Customer\CollectionFactory'
52-
)->setMethods(['create'])
53-
->disableOriginalConstructor()
54-
->getMockForAbstractClass();
55-
$this->eavValidationRulesMock = $this->getMockBuilder('Magento\Ui\DataProvider\EavValidationRules')
51+
$this->customerCollectionFactoryMock = $this->getMock(
52+
'Magento\Customer\Model\Resource\Customer\CollectionFactory',
53+
['create'],
54+
[],
55+
'',
56+
false
57+
);
58+
$this->eavValidationRulesMock = $this
59+
->getMockBuilder('Magento\Ui\DataProvider\EavValidationRules')
5660
->disableOriginalConstructor()
5761
->getMock();
5862
}
@@ -67,13 +71,17 @@ protected function setUp()
6771
*/
6872
public function testGetAttributesMetaWithOptions(array $expected)
6973
{
70-
$dataProvider = new DataProvider(
71-
'test-name',
72-
'primary-field-name',
73-
'request-field-name',
74-
$this->eavValidationRulesMock,
75-
$this->getCustomerCollectionFactoryMock(),
76-
$this->getEavConfigMock()
74+
$helper = new ObjectManager($this);
75+
$dataProvider = $helper->getObject(
76+
'\Magento\Customer\Model\Customer\DataProvider',
77+
[
78+
'name' => 'test-name',
79+
'primaryFieldName' => 'primary-field-name',
80+
'requestFieldName' => 'request-field-name',
81+
'eavValidationRules' => $this->eavValidationRulesMock,
82+
'customerCollectionFactory' => $this->getCustomerCollectionFactoryMock(),
83+
'eavConfig' => $this->getEavConfigMock()
84+
]
7785
);
7886

7987
$meta = $dataProvider->getMeta();

0 commit comments

Comments
 (0)