|
7 | 7 |
|
8 | 8 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
9 | 9 | use Magento\Customer\Api\Data\AttributeMetadataInterface;
|
10 |
| -use Magento\Customer\Api\Data\AttributeMetadataInterfaceFactory; |
11 |
| -use Magento\Customer\Api\Data\OptionInterfaceFactory; |
12 |
| -use Magento\Customer\Api\Data\ValidationRuleInterfaceFactory; |
13 | 10 | use Magento\Customer\Model\Data\AttributeMetadata;
|
| 11 | +use Magento\Customer\Api\Data\AttributeMetadataInterfaceFactory; |
| 12 | +use Magento\Customer\Api\Data\OptionInterface; |
14 | 13 | use Magento\Customer\Model\Data\Option;
|
| 14 | +use Magento\Customer\Api\Data\OptionInterfaceFactory; |
| 15 | +use Magento\Customer\Api\Data\ValidationRuleInterface; |
15 | 16 | use Magento\Customer\Model\Data\ValidationRule;
|
16 |
| -use Magento\Framework\Reflection\DataObjectProcessor; |
| 17 | +use Magento\Customer\Api\Data\ValidationRuleInterfaceFactory; |
17 | 18 | use Magento\Customer\Model\Metadata\AttributeMetadataHydrator;
|
| 19 | +use Magento\Framework\Reflection\DataObjectProcessor; |
18 | 20 |
|
19 | 21 | class AttributeMetadataHydratorTest extends \PHPUnit_Framework_TestCase
|
20 | 22 | {
|
@@ -168,18 +170,43 @@ public function testHydrate()
|
168 | 170 |
|
169 | 171 | $attributeMetadata = $this->attributeMetadataHydrator->hydrate($attributeMetadataData);
|
170 | 172 |
|
| 173 | + $this->assertInstanceOf(AttributeMetadataInterface::class, $attributeMetadata); |
171 | 174 | $this->assertEquals(
|
172 | 175 | $attributeMetadataData['attribute_code'],
|
173 | 176 | $attributeMetadata->getAttributeCode()
|
174 | 177 | );
|
| 178 | + $this->assertInternalType( |
| 179 | + \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, |
| 180 | + $attributeMetadata->getOptions() |
| 181 | + ); |
| 182 | + $this->assertArrayHasKey( |
| 183 | + 0, |
| 184 | + $attributeMetadata->getOptions() |
| 185 | + ); |
| 186 | + $this->assertInstanceOf(OptionInterface::class, $attributeMetadata->getOptions()[0]); |
175 | 187 | $this->assertEquals(
|
176 | 188 | $optionOneData['label'],
|
177 | 189 | $attributeMetadata->getOptions()[0]->getLabel()
|
178 | 190 | );
|
| 191 | + $this->assertArrayHasKey(1, $attributeMetadata->getOptions()); |
| 192 | + $this->assertInstanceOf(OptionInterface::class, $attributeMetadata->getOptions()[1]); |
| 193 | + |
| 194 | + $this->assertInternalType( |
| 195 | + \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, |
| 196 | + $attributeMetadata->getOptions()[1]->getOptions() |
| 197 | + ); |
| 198 | + $this->assertArrayHasKey(0, $attributeMetadata->getOptions()[1]->getOptions()); |
| 199 | + $this->assertInstanceOf(OptionInterface::class, $attributeMetadata->getOptions()[1]->getOptions()[0]); |
179 | 200 | $this->assertEquals(
|
180 | 201 | $optionThreeData['label'],
|
181 | 202 | $attributeMetadata->getOptions()[1]->getOptions()[0]->getLabel()
|
182 | 203 | );
|
| 204 | + $this->assertInternalType( |
| 205 | + \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, |
| 206 | + $attributeMetadata->getValidationRules() |
| 207 | + ); |
| 208 | + $this->assertArrayHasKey(0, $attributeMetadata->getValidationRules()); |
| 209 | + $this->assertInstanceOf(ValidationRuleInterface::class, $attributeMetadata->getValidationRules()[0]); |
183 | 210 | $this->assertEquals(
|
184 | 211 | $validationRuleOneData['name'],
|
185 | 212 | $attributeMetadata->getValidationRules()[0]->getName()
|
|
0 commit comments