Exemplo n.º 1
0
 public function testConstructorAndGetters()
 {
     $options = array(array('value' => 'OPTION_ONE'), array('value' => 'OPTION_TWO'));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     /** @var \Magento\Customer\Service\V1\Data\Eav\OptionBuilder $optionBuilder */
     $optionBuilder = $objectManager->getObject('Magento\\Customer\\Service\\V1\\Data\\Eav\\OptionBuilder');
     $validationRuleBuilder = $objectManager->getObject('Magento\\Customer\\Service\\V1\\Data\\Eav\\ValidationRuleBuilder');
     $attributeMetadataBuilder = $objectManager->getObject('\\Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadataBuilder', ['optionBuilder' => $optionBuilder, 'validationRuleBuilder' => $validationRuleBuilder])->populateWithArray(array('attribute_code' => self::ATTRIBUTE_CODE, 'frontend_input' => self::FRONTEND_INPUT, 'input_filter' => self::INPUT_FILTER, 'store_label' => self::STORE_LABEL, 'validation_rules' => array(), 'options' => $options));
     $attributeMetadata = new AttributeMetadata($attributeMetadataBuilder);
     $this->assertSame(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode());
     $this->assertSame(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput());
     $this->assertSame(self::INPUT_FILTER, $attributeMetadata->getInputFilter());
     $this->assertSame(self::STORE_LABEL, $attributeMetadata->getStoreLabel());
     $this->assertSame(array(), $attributeMetadata->getValidationRules());
     $this->assertSame($options[0], $attributeMetadata->getOptions()[0]->__toArray());
     $this->assertSame($options[1], $attributeMetadata->getOptions()[1]->__toArray());
 }
Exemplo n.º 2
0
 /**
  * @param \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata $attribute
  * @return array
  */
 protected function _getAttributeOptionsArray(\Magento\Customer\Service\V1\Data\Eav\AttributeMetadata $attribute)
 {
     $options = $attribute->getOptions();
     $result = array();
     foreach ($options as $option) {
         $result[] = $option->__toArray();
     }
     return $result;
 }