Ejemplo n.º 1
0
 public function testGetAttributes()
 {
     $formAttributesMetadata = $this->_service->getAttributes('customer_address_edit');
     $this->assertCount(15, $formAttributesMetadata, "Invalid number of attributes for the specified form.");
     /** Check some fields of one attribute metadata */
     $attributeMetadata = $formAttributesMetadata['company'];
     $this->assertInstanceOf('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata', $attributeMetadata);
     $this->assertEquals('company', $attributeMetadata->getAttributeCode(), 'Attribute code is invalid');
     $this->assertNotEmpty($attributeMetadata->getValidationRules(), 'Validation rules are not set');
     $this->assertEquals('varchar', $attributeMetadata->getBackendType(), 'Backend type is invalid');
     $this->assertEquals('Company', $attributeMetadata->getFrontendLabel(), 'Frontend label is invalid');
 }
Ejemplo n.º 2
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;
 }