11 class DataTest extends \PHPUnit\Framework\TestCase
43 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
45 $this->attributeConfig = $this->createMock(\
Magento\Eav\Model\Entity\Attribute\Config::class);
46 $this->eavConfig = $this->createMock(\
Magento\Eav\Model\Config::class);
47 $this->context = $this->createPartialMock(\
Magento\Framework\
App\Helper\Context::class, [
'getScopeConfig']);
49 $this->scopeConfigMock = $this->createMock(\
Magento\Framework\
App\Config\ScopeConfigInterface::class);
50 $this->context->expects($this->once())->method(
'getScopeConfig')->willReturn($this->scopeConfigMock);
53 \
Magento\Eav\Helper\Data::class,
55 'attributeConfig' => $this->attributeConfig,
56 'eavConfig' => $this->eavConfig,
57 'context' => $this->context,
64 $attribute = new \Magento\Framework\DataObject([
65 'entity_type_id' =>
'1',
66 'attribute_id' =>
'2',
67 'backend' =>
new \
Magento\Framework\DataObject([
'table' =>
'customer_entity_varchar']),
68 'backend_type' =>
'varchar',
70 $this->eavConfig->expects($this->once())
71 ->method(
'getAttribute')
74 $result = $this->helper->getAttributeMetadata(
'customer',
'lastname');
76 'entity_type_id' =>
'1',
77 'attribute_id' =>
'2',
78 'attribute_table' =>
'customer_entity_varchar',
79 'backend_type' =>
'varchar',
83 $this->assertArrayHasKey($key, $expected,
'Attribute metadata with key "' . $key .
'" not found.');
87 'Attribute metadata with key "' . $key .
'" has invalid value.' 98 $result = $this->helper->getFrontendClasses(
'someNonExistedClass');
99 $this->assertTrue(count(
$result) > 1);
100 $this->assertContains([
'value' =>
'',
'label' =>
'None'],
$result);
101 $this->assertContains([
'value' =>
'validate-number',
'label' =>
'Decimal Number'],
$result);
109 $this->attributeConfig->expects($this->never())->method(
'getEntityAttributesLockedFields');
110 $this->assertEquals([], $this->helper->getAttributeLockedFields(
''));
118 $lockedFields = [
'lockedField1',
'lockedField2'];
120 $this->attributeConfig->expects($this->once())->method(
'getEntityAttributesLockedFields')
121 ->with(
'entityTypeCode')->will($this->returnValue($lockedFields));
122 $this->assertEquals($lockedFields, $this->helper->getAttributeLockedFields(
'entityTypeCode'));
130 $lockedFields = [
'lockedField1',
'lockedField2'];
132 $this->attributeConfig->expects($this->once())->method(
'getEntityAttributesLockedFields')
133 ->with(
'entityTypeCode')->will($this->returnValue($lockedFields));
135 $this->helper->getAttributeLockedFields(
'entityTypeCode');
136 $this->assertEquals($lockedFields, $this->helper->getAttributeLockedFields(
'entityTypeCode'));
144 $this->attributeConfig->expects($this->once())->method(
'getEntityAttributesLockedFields')
145 ->with(
'entityTypeCode')->will($this->returnValue([]));
147 $this->assertEquals([], $this->helper->getAttributeLockedFields(
'entityTypeCode'));
152 $configValue =
'config_value';
153 $this->scopeConfigMock->expects($this->once())
156 ->willReturn($configValue);
158 $this->assertEquals($configValue, $this->helper->getInputTypesValidatorData());
testGetAttributeLockedFieldsCachedLockedFiled()
testGetAttributeLockedFieldsNonCachedLockedFiled()
testGetAttributeLockedFieldsNoEntityCode()
testGetInputTypesValidatorData()
testGetAttributeMetadata()
testGetAttributeLockedFieldsNoLockedFields()