Esempio n. 1
0
 /**
  * Retrieve attributes metadata for the form
  *
  * @return \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata[]
  */
 public function getAttributes()
 {
     if (!isset($this->_attributes)) {
         $this->_attributes = $this->_eavMetadataService->getAttributes($this->_entityType, $this->_formCode);
     }
     return $this->_attributes;
 }
 public function testGetAttributes()
 {
     $formAttributesMetadata = $this->_service->getAttributes('adminhtml_customer');
     $this->assertCount(14, $formAttributesMetadata, "Invalid number of attributes for the specified form.");
     /** Check some fields of one attribute metadata */
     $attributeMetadata = $formAttributesMetadata['firstname'];
     $this->assertInstanceOf('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata', $attributeMetadata);
     $this->assertEquals('firstname', $attributeMetadata->getAttributeCode(), 'Attribute code is invalid');
     $this->assertNotEmpty($attributeMetadata->getValidationRules(), 'Validation rules are not set');
     $this->assertEquals('1', $attributeMetadata->isSystem(), '"Is system" field value is invalid');
     $this->assertEquals('40', $attributeMetadata->getSortOrder(), 'Sort order is invalid');
 }
Esempio n. 3
0
 /**
  * Retrieve attributes metadata for the form
  *
  * @return \Magento\Customer\Service\V1\Data\Eav\AttributeMetadata[]
  * @throws \LogicException For undefined entity type
  */
 public function getAttributes()
 {
     if (!isset($this->_attributes)) {
         if ($this->_entityType === CustomerMetadataServiceInterface::ENTITY_TYPE_CUSTOMER) {
             $this->_attributes = $this->_customerMetadataService->getAttributes($this->_formCode);
         } else {
             if ($this->_entityType === AddressMetadataServiceInterface::ENTITY_TYPE_ADDRESS) {
                 $this->_attributes = $this->_addressMetadataService->getAttributes($this->_formCode);
             } else {
                 throw new \LogicException('Undefined entity type: ' . $this->_entityType);
             }
         }
     }
     return $this->_attributes;
 }