/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/MultilineTest.php
103 строки
3 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 10:44
22 окт 2025, 10:44
264bea2
Код
Авторство
О чём код?
<?php /** * Copyright 2023 Adobe * All Rights Reserved. */ declare(strict_types=1); namespace Magento\GraphQl\Customer\Attribute; use Magento\Customer\Api\CustomerMetadataInterface; use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Customer\Test\Fixture\CustomerAttribute; use Magento\TestFramework\Fixture\DataFixture; use Magento\TestFramework\Fixture\DataFixtureStorageManager; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\GraphQlAbstract; /** * Test catalog EAV attributes metadata retrieval via GraphQL API */ class MultilineTest extends GraphQlAbstract { private const QUERY = <<<QRY { customAttributeMetadataV2(attributes: [{attribute_code: "%s", entity_type: "%s"}]) { items { code label entity_type frontend_input is_required default_value is_unique ... on CustomerAttributeMetadata { input_filter multiline_count sort_order validate_rules { name value } } } errors { type message } } } QRY; #[ DataFixture( CustomerAttribute::class, [ 'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, 'frontend_input' => 'multiline', 'default_value' => 'this is line one 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 AttributeMetadataInterface $attribute */ $attribute = DataFixtureStorageManager::getStorage()->get('attribute'); $formattedValidationRules = Bootstrap::getObjectManager()->get(FormatValidationRulesCommand::class)->execute( $attribute->getValidationRules() ); $result = $this->graphQlQuery(sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer')); $this->assertEquals( [ 'customAttributeMetadataV2' => [ 'items' => [ [ 'code' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel(), 'entity_type' => 'CUSTOMER', 'frontend_input' => 'MULTILINE', 'is_required' => false, 'default_value' => $attribute->getDefaultValue(), 'is_unique' => false, 'input_filter' => $attribute->getInputFilter(), 'multiline_count' => $attribute->getMultilineCount(), 'sort_order' => $attribute->getSortOrder(), 'validate_rules' => $formattedValidationRules ] ], 'errors' => [] ] ], $result ); } }