diff --git a/app/code/Magento/Customer/Test/Fixture/CustomerAttribute.php b/app/code/Magento/Customer/Test/Fixture/CustomerAttribute.php
index a3521ccc749ad..032299c2024d1 100644
--- a/app/code/Magento/Customer/Test/Fixture/CustomerAttribute.php
+++ b/app/code/Magento/Customer/Test/Fixture/CustomerAttribute.php
@@ -39,6 +39,9 @@ class CustomerAttribute implements RevertibleDataFixtureInterface
'sort_order' => null,
'attribute_set_id' => null,
'attribute_group_id' => null,
+ 'input_filter' => null,
+ 'multiline_count' => 0,
+ 'validate_rules' => null
];
/**
diff --git a/app/code/Magento/CustomerGraphQl/Model/Output/CustomerAttributeMetadata.php b/app/code/Magento/CustomerGraphQl/Model/Output/CustomerAttributeMetadata.php
new file mode 100644
index 0000000000000..fcc412b74b62b
--- /dev/null
+++ b/app/code/Magento/CustomerGraphQl/Model/Output/CustomerAttributeMetadata.php
@@ -0,0 +1,122 @@
+attributeUid = $attributeUid;
+ $this->uid = $uid;
+ $this->enumLookup = $enumLookup;
+ $this->metadata = $metadata;
+ $this->entityType = $entityType;
+ }
+
+ /**
+ * Retrieve formatted attribute data
+ *
+ * @param AttributeInterface $attribute
+ * @param string $entityType
+ * @param int $storeId
+ * @return array
+ * @throws LocalizedException
+ * @throws NoSuchEntityException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function execute(
+ AttributeInterface $attribute,
+ string $entityType,
+ int $storeId
+ ): array {
+ if ($entityType !== $this->entityType) {
+ return [];
+ }
+
+ $attributeMetadata = $this->metadata->getAttributeMetadata($attribute->getAttributeCode());
+ $data = [];
+
+ $validationRules = array_map(function (ValidationRule $validationRule) {
+ return [
+ 'name' => $this->enumLookup->getEnumValueFromField(
+ 'ValidationRuleEnum',
+ strtoupper($validationRule->getName())
+ ),
+ 'value' => $validationRule->getValue()
+ ];
+ }, $attributeMetadata->getValidationRules());
+
+ if ($attributeMetadata->isVisible()) {
+ $data = [
+ 'input_filter' =>
+ empty($attributeMetadata->getInputFilter())
+ ? 'NONE'
+ : $this->enumLookup->getEnumValueFromField(
+ 'InputFilterEnum',
+ strtoupper($attributeMetadata->getInputFilter())
+ ),
+ 'multiline_count' => $attributeMetadata->getMultilineCount(),
+ 'sort_order' => $attributeMetadata->getSortOrder(),
+ 'validate_rules' => $validationRules,
+ 'attributeMetadata' => $attributeMetadata
+ ];
+ }
+
+ return $data;
+ }
+}
diff --git a/app/code/Magento/CustomerGraphQl/etc/graphql/di.xml b/app/code/Magento/CustomerGraphQl/etc/graphql/di.xml
index 3813a90989633..f6d3d7c30b8d9 100644
--- a/app/code/Magento/CustomerGraphQl/etc/graphql/di.xml
+++ b/app/code/Magento/CustomerGraphQl/etc/graphql/di.xml
@@ -40,6 +40,34 @@
+
+
+
+ - CustomerAttributeMetadata
+ - CustomerAttributeMetadata
+
+
+
+
+
+
+ - GetCustomerAttributesMetadata
+ - GetCustomerAddressAttributesMetadata
+
+
+
+
+
+ Magento\Customer\Model\Metadata\CustomerMetadata
+ customer
+
+
+
+
+ Magento\Customer\Model\Metadata\AddressMetadata
+ customer_address
+
+
@@ -69,6 +97,24 @@
- customer
- customer_address
+ -
+
- NONE
+ - DATE
+ - TRIM
+ - STRIPTAGS
+ - ESCAPEHTML
+
+ -
+
- DATE_RANGE_MAX
+ - DATE_RANGE_MIN
+ - FILE_EXTENSIONS
+ - INPUT_VALIDATION
+ - MAX_TEXT_LENGTH
+ - MIN_TEXT_LENGTH
+ - MAX_FILE_SIZE
+ - MAX_IMAGE_HEGHT
+ - MAX_IMAGE_WIDTH
+
diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
index 433c8097fc73b..0d51bd0c91f48 100644
--- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
@@ -431,3 +431,35 @@ enum AttributeEntityTypeEnum {
CUSTOMER
CUSTOMER_ADDRESS
}
+
+type CustomerAttributeMetadata implements AttributeMetadataInterface @doc(description: "Customer attribute metadata.") {
+ input_filter: InputFilterEnum @doc(description: "The template used for the input of the attribute (e.g., 'date').")
+ multiline_count: Int @doc(description: "The number of lines of the attribute value.")
+ sort_order: Int @doc(description: "The position of the attribute in the form.")
+ validate_rules: [ValidationRule] @doc(description: "The validation rules of the attribute value.")
+}
+
+enum InputFilterEnum @doc(description: "List of templates/filters applied to customer attribute input.") {
+ NONE @doc(description: "There are no templates or filters to be applied.")
+ DATE @doc(description: "Forces attribute input to follow the date format.")
+ TRIM @doc(description: "Strip whitespace (or other characters) from the beginning and end of the input.")
+ STRIPTAGS @doc(description: "Strip HTML Tags.")
+ ESCAPEHTML @doc(description: "Escape HTML Entities.")
+}
+
+type ValidationRule @doc(description: "Defines a customer attribute validation rule.") {
+ name: ValidationRuleEnum @doc(description: "Validation rule name applied to a customer attribute.")
+ value: String @doc(description: "Validation rule value.")
+}
+
+enum ValidationRuleEnum @doc(description: "List of validation rule names applied to a customer attribute.") {
+ DATE_RANGE_MAX
+ DATE_RANGE_MIN
+ FILE_EXTENSIONS
+ INPUT_VALIDATION
+ MAX_TEXT_LENGTH
+ MIN_TEXT_LENGTH
+ MAX_FILE_SIZE
+ MAX_IMAGE_HEIGHT
+ MAX_IMAGE_WIDTH
+}
diff --git a/app/code/Magento/EavGraphQl/etc/schema.graphqls b/app/code/Magento/EavGraphQl/etc/schema.graphqls
index 147cdc151355c..96b4c08ea994e 100644
--- a/app/code/Magento/EavGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/EavGraphQl/etc/schema.graphqls
@@ -113,7 +113,6 @@ type AttributesFormOutput @doc(description: "Metadata of EAV attributes associat
errors: [AttributeMetadataError!]! @doc(description: "Errors of retrieving certain attributes metadata.")
}
-
interface AttributeValueInterface @typeResolver(class: "Magento\\EavGraphQl\\Model\\TypeResolver\\AttributeValue") {
uid: ID! @doc(description: "The unique ID of an attribute value.")
code: String! @doc(description: "The attribute code.")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/BooleanTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/BooleanTest.php
index de23fbf52a5a0..b9e7f0f259544 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/BooleanTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/BooleanTest.php
@@ -8,8 +8,8 @@
namespace Magento\GraphQl\Customer\Attribute;
use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Eav\Api\Data\AttributeInterface;
-use Magento\Eav\Test\Fixture\Attribute;
+use Magento\Customer\Api\Data\AttributeMetadataInterface;
+use Magento\Customer\Test\Fixture\CustomerAttribute;
use Magento\EavGraphQl\Model\Uid;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -49,7 +49,7 @@ class BooleanTest extends GraphQlAbstract
#[
DataFixture(
- Attribute::class,
+ CustomerAttribute::class,
[
'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
'frontend_input' => 'boolean',
@@ -60,7 +60,7 @@ class BooleanTest extends GraphQlAbstract
]
public function testMetadata(): void
{
- /** @var AttributeInterface $attribute */
+ /** @var AttributeMetadataInterface $attribute */
$attribute = DataFixtureStorageManager::getStorage()->get('attribute');
$uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
@@ -77,7 +77,7 @@ public function testMetadata(): void
[
'uid' => $uid,
'code' => $attribute->getAttributeCode(),
- 'label' => $attribute->getDefaultFrontendLabel(),
+ 'label' => $attribute->getFrontendLabel(),
'entity_type' => 'CUSTOMER',
'frontend_input' => 'BOOLEAN',
'is_required' => false,
@@ -95,7 +95,6 @@ public function testMetadata(): void
'value' => '0'
]
]
-
]
],
'errors' => []
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/CustomerAddressAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/CustomerAddressAttributesTest.php
new file mode 100644
index 0000000000000..72c7c59999711
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/CustomerAddressAttributesTest.php
@@ -0,0 +1,107 @@
+ AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS,
+ 'frontend_input' => 'date',
+ 'default_value' => '2023-03-22 00:00:00',
+ 'input_filter' => 'DATE',
+ 'validate_rules' =>
+ '{"DATE_RANGE_MIN":"1679443200","DATE_RANGE_MAX":"1679875200","INPUT_VALIDATION":"DATE"}'
+ ],
+ 'attribute'
+ ),
+ ]
+ public function testMetadata(): void
+ {
+ /** @var AttributeMetadataInterface $attribute */
+ $attribute = DataFixtureStorageManager::getStorage()->get('attribute');
+
+ $uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
+ 'customer_address',
+ $attribute->getAttributeCode()
+ );
+
+ $formattedValidationRules = Bootstrap::getObjectManager()->get(FormatValidationRulesCommand::class)->execute(
+ $attribute->getValidationRules()
+ );
+
+ $result = $this->graphQlQuery(
+ sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer_address')
+ );
+
+ $this->assertEquals(
+ [
+ 'attributesMetadata' => [
+ 'items' => [
+ [
+ 'uid' => $uid,
+ 'code' => $attribute->getAttributeCode(),
+ 'label' => $attribute->getFrontendLabel(),
+ 'entity_type' => 'CUSTOMER_ADDRESS',
+ 'frontend_input' => 'DATE',
+ 'is_required' => false,
+ 'default_value' => $attribute->getDefaultValue(),
+ 'is_unique' => false,
+ 'input_filter' => $attribute->getInputFilter(),
+ 'validate_rules' => $formattedValidationRules
+ ]
+ ],
+ 'errors' => []
+ ]
+ ],
+ $result
+ );
+ }
+}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/DateTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/DateTest.php
index 190e81bea0fbd..4f2a076358e6f 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/DateTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/DateTest.php
@@ -8,8 +8,8 @@
namespace Magento\GraphQl\Customer\Attribute;
use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Eav\Api\Data\AttributeInterface;
-use Magento\Eav\Test\Fixture\Attribute;
+use Magento\Customer\Api\Data\AttributeMetadataInterface;
+use Magento\Customer\Test\Fixture\CustomerAttribute;
use Magento\EavGraphQl\Model\Uid;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -33,6 +33,13 @@ class DateTest extends GraphQlAbstract
is_required
default_value
is_unique
+ ... on CustomerAttributeMetadata {
+ input_filter
+ validate_rules {
+ name
+ value
+ }
+ }
}
errors {
type
@@ -44,18 +51,21 @@ class DateTest extends GraphQlAbstract
#[
DataFixture(
- Attribute::class,
+ CustomerAttribute::class,
[
'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
'frontend_input' => 'date',
- 'default_value' => '2023-03-22 00:00:00'
+ 'default_value' => '2023-03-22 00:00:00',
+ 'input_filter' => 'DATE',
+ 'validate_rules' =>
+ '{"DATE_RANGE_MIN":"1679443200","DATE_RANGE_MAX":"1679875200","INPUT_VALIDATION":"DATE"}'
],
'attribute'
- )
+ ),
]
public function testMetadata(): void
{
- /** @var AttributeInterface $attribute */
+ /** @var AttributeMetadataInterface $attribute */
$attribute = DataFixtureStorageManager::getStorage()->get('attribute');
$uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
@@ -63,6 +73,10 @@ public function testMetadata(): void
$attribute->getAttributeCode()
);
+ $formattedValidationRules = Bootstrap::getObjectManager()->get(FormatValidationRulesCommand::class)->execute(
+ $attribute->getValidationRules()
+ );
+
$result = $this->graphQlQuery(sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer'));
$this->assertEquals(
@@ -72,12 +86,14 @@ public function testMetadata(): void
[
'uid' => $uid,
'code' => $attribute->getAttributeCode(),
- 'label' => $attribute->getDefaultFrontendLabel(),
+ 'label' => $attribute->getFrontendLabel(),
'entity_type' => 'CUSTOMER',
'frontend_input' => 'DATE',
'is_required' => false,
'default_value' => $attribute->getDefaultValue(),
'is_unique' => false,
+ 'input_filter' => $attribute->getInputFilter(),
+ 'validate_rules' => $formattedValidationRules
]
],
'errors' => []
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FileTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FileTest.php
index d88c19df82309..7caef046583e2 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FileTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FileTest.php
@@ -8,8 +8,8 @@
namespace Magento\GraphQl\Customer\Attribute;
use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Eav\Api\Data\AttributeInterface;
-use Magento\Eav\Test\Fixture\Attribute;
+use Magento\Customer\Api\Data\AttributeMetadataInterface;
+use Magento\Customer\Test\Fixture\CustomerAttribute;
use Magento\EavGraphQl\Model\Uid;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -33,6 +33,12 @@ class FileTest extends GraphQlAbstract
is_required
default_value
is_unique
+ ... on CustomerAttributeMetadata {
+ validate_rules {
+ name
+ value
+ }
+ }
}
errors {
type
@@ -44,17 +50,18 @@ class FileTest extends GraphQlAbstract
#[
DataFixture(
- Attribute::class,
+ CustomerAttribute::class,
[
'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
- 'frontend_input' => 'file'
+ 'frontend_input' => 'file',
+ 'validate_rules' => '{"MAX_FILE_SIZE":"10000000","FILE_EXTENSIONS":"PDF"}'
],
'attribute'
)
]
public function testMetadata(): void
{
- /** @var AttributeInterface $attribute */
+ /** @var AttributeMetadataInterface $attribute */
$attribute = DataFixtureStorageManager::getStorage()->get('attribute');
$uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
@@ -62,6 +69,10 @@ public function testMetadata(): void
$attribute->getAttributeCode()
);
+ $formattedValidationRules = Bootstrap::getObjectManager()->get(FormatValidationRulesCommand::class)->execute(
+ $attribute->getValidationRules()
+ );
+
$result = $this->graphQlQuery(sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer'));
$this->assertEquals(
@@ -71,12 +82,13 @@ public function testMetadata(): void
[
'uid' => $uid,
'code' => $attribute->getAttributeCode(),
- 'label' => $attribute->getDefaultFrontendLabel(),
+ 'label' => $attribute->getFrontendLabel(),
'entity_type' => 'CUSTOMER',
'frontend_input' => 'FILE',
'is_required' => false,
'default_value' => $attribute->getDefaultValue(),
'is_unique' => false,
+ 'validate_rules' => $formattedValidationRules
]
],
'errors' => []
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FormatValidationRulesCommand.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FormatValidationRulesCommand.php
new file mode 100644
index 0000000000000..8a0891424a450
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/FormatValidationRulesCommand.php
@@ -0,0 +1,29 @@
+ $value) {
+ $formattedValidationRules[] = ['name' => $key, 'value' => $value];
+ }
+ return $formattedValidationRules;
+ }
+}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/ImageTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/ImageTest.php
index fe2dfb19d9472..ef5d5a1a1429e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/ImageTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/ImageTest.php
@@ -8,8 +8,8 @@
namespace Magento\GraphQl\Customer\Attribute;
use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Eav\Api\Data\AttributeInterface;
-use Magento\Eav\Test\Fixture\Attribute;
+use Magento\Customer\Api\Data\AttributeMetadataInterface;
+use Magento\Customer\Test\Fixture\CustomerAttribute;
use Magento\EavGraphQl\Model\Uid;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -33,6 +33,12 @@ class ImageTest extends GraphQlAbstract
is_required
default_value
is_unique
+ ... on CustomerAttributeMetadata {
+ validate_rules {
+ name
+ value
+ }
+ }
}
errors {
type
@@ -44,17 +50,18 @@ class ImageTest extends GraphQlAbstract
#[
DataFixture(
- Attribute::class,
+ CustomerAttribute::class,
[
'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
- 'frontend_input' => 'image'
+ 'frontend_input' => 'image',
+ 'validate_rules' => '{"MAX_FILE_SIZE":"10000","MAX_IMAGE_WIDTH":"100"}'
],
'attribute'
)
]
public function testMetadata(): void
{
- /** @var AttributeInterface $attribute */
+ /** @var AttributeMetadataInterface $attribute */
$attribute = DataFixtureStorageManager::getStorage()->get('attribute');
$uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
@@ -62,6 +69,10 @@ public function testMetadata(): void
$attribute->getAttributeCode()
);
+ $formattedValidationRules = Bootstrap::getObjectManager()->get(FormatValidationRulesCommand::class)->execute(
+ $attribute->getValidationRules()
+ );
+
$result = $this->graphQlQuery(sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer'));
$this->assertEquals(
@@ -71,12 +82,13 @@ public function testMetadata(): void
[
'uid' => $uid,
'code' => $attribute->getAttributeCode(),
- 'label' => $attribute->getDefaultFrontendLabel(),
+ 'label' => $attribute->getFrontendLabel(),
'entity_type' => 'CUSTOMER',
'frontend_input' => 'IMAGE',
'is_required' => false,
'default_value' => $attribute->getDefaultValue(),
'is_unique' => false,
+ 'validate_rules' => $formattedValidationRules
]
],
'errors' => []
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/MultilineTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/MultilineTest.php
index 19687ee64fa5a..44b244222d36e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/MultilineTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/MultilineTest.php
@@ -8,8 +8,8 @@
namespace Magento\GraphQl\Customer\Attribute;
use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Eav\Api\Data\AttributeInterface;
-use Magento\Eav\Test\Fixture\Attribute;
+use Magento\Customer\Api\Data\AttributeMetadataInterface;
+use Magento\Customer\Test\Fixture\CustomerAttribute;
use Magento\EavGraphQl\Model\Uid;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -33,10 +33,14 @@ class MultilineTest extends GraphQlAbstract
is_required
default_value
is_unique
- options {
- uid
- label
- value
+ ... on CustomerAttributeMetadata {
+ input_filter
+ multiline_count
+ sort_order
+ validate_rules {
+ name
+ value
+ }
}
}
errors {
@@ -49,19 +53,23 @@ class MultilineTest extends GraphQlAbstract
#[
DataFixture(
- Attribute::class,
+ CustomerAttribute::class,
[
'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
'frontend_input' => 'multiline',
'default_value' => 'this is line one
-this is line two'
+this is line two',
+ 'input_filter' => 'STRIPTAGS',
+ 'multiline_count' => 2,
+ 'sort_order' => 3,
+ 'validate_rules' => '{"MIN_TEXT_LENGTH":"100","MAX_TEXT_LENGTH":"200","INPUT_VALIDATION":"EMAIL"}',
],
'attribute'
)
]
public function testMetadata(): void
{
- /** @var AttributeInterface $attribute */
+ /** @var AttributeMetadataInterface $attribute */
$attribute = DataFixtureStorageManager::getStorage()->get('attribute');
$uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
@@ -69,6 +77,10 @@ public function testMetadata(): void
$attribute->getAttributeCode()
);
+ $formattedValidationRules = Bootstrap::getObjectManager()->get(FormatValidationRulesCommand::class)->execute(
+ $attribute->getValidationRules()
+ );
+
$result = $this->graphQlQuery(sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer'));
$this->assertEquals(
@@ -78,13 +90,16 @@ public function testMetadata(): void
[
'uid' => $uid,
'code' => $attribute->getAttributeCode(),
- 'label' => $attribute->getDefaultFrontendLabel(),
+ 'label' => $attribute->getFrontendLabel(),
'entity_type' => 'CUSTOMER',
'frontend_input' => 'MULTILINE',
'is_required' => false,
'default_value' => $attribute->getDefaultValue(),
'is_unique' => false,
- 'options' => []
+ 'input_filter' => $attribute->getInputFilter(),
+ 'multiline_count' => $attribute->getMultilineCount(),
+ 'sort_order' => $attribute->getSortOrder(),
+ 'validate_rules' => $formattedValidationRules
]
],
'errors' => []
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/TextareaTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/TextareaTest.php
index 6abf824336202..6c0a96720a219 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/TextareaTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/TextareaTest.php
@@ -8,8 +8,8 @@
namespace Magento\GraphQl\Customer\Attribute;
use Magento\Customer\Api\CustomerMetadataInterface;
-use Magento\Eav\Api\Data\AttributeInterface;
-use Magento\Eav\Test\Fixture\Attribute;
+use Magento\Customer\Api\Data\AttributeMetadataInterface;
+use Magento\Customer\Test\Fixture\CustomerAttribute;
use Magento\EavGraphQl\Model\Uid;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
@@ -33,6 +33,10 @@ class TextareaTest extends GraphQlAbstract
is_required
default_value
is_unique
+ ... on CustomerAttributeMetadata {
+ input_filter
+ sort_order
+ }
}
errors {
type
@@ -44,7 +48,7 @@ class TextareaTest extends GraphQlAbstract
#[
DataFixture(
- Attribute::class,
+ CustomerAttribute::class,
[
'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
'frontend_input' => 'textarea',
@@ -57,14 +61,16 @@ class TextareaTest extends GraphQlAbstract
'metus mattis ultrices non nec libero. Cras odio nunc, eleifend vitae interdum a, '.
'porttitor a dolor. Praesent mi odio, hendrerit quis consequat nec, vestibulum ' .
'vitae justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin auctor' .
- 'ac quam id rhoncus. Proin vel orci eu justo cursus vestibulum.'
+ 'ac quam id rhoncus. Proin vel orci eu justo cursus vestibulum.',
+ 'input_filter' => 'ESCAPEHTML',
+ 'sort_order' => 4,
],
'attribute'
)
]
public function testMetadata(): void
{
- /** @var AttributeInterface $attribute */
+ /** @var AttributeMetadataInterface $attribute */
$attribute = DataFixtureStorageManager::getStorage()->get('attribute');
$uid = Bootstrap::getObjectManager()->get(Uid::class)->encode(
@@ -81,12 +87,14 @@ public function testMetadata(): void
[
'uid' => $uid,
'code' => $attribute->getAttributeCode(),
- 'label' => $attribute->getDefaultFrontendLabel(),
+ 'label' => $attribute->getFrontendLabel(),
'entity_type' => 'CUSTOMER',
'frontend_input' => 'TEXTAREA',
'is_required' => false,
'default_value' => $attribute->getDefaultValue(),
'is_unique' => false,
+ 'input_filter' => $attribute->getInputFilter(),
+ 'sort_order' => $attribute->getSortOrder(),
]
],
'errors' => []