CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, 'frontend_input' => 'multiselect', 'source_model' => Table::class ], 'attribute' ), DataFixture( AttributeOption::class, [ 'entity_type' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, 'attribute_code' => '$attribute.attribute_code$', 'sort_order' => 10 ], 'option1' ), DataFixture( AttributeOption::class, [ 'entity_type' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, 'attribute_code' => '$attribute.attribute_code$', 'sort_order' => 20, 'is_default' => true ], 'option2' ), DataFixture( AttributeOption::class, [ 'entity_type' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, 'attribute_code' => '$attribute.attribute_code$', 'sort_order' => 30, 'is_default' => true ], 'option3' ), ] public function testMetadata(): void { /** @var AttributeInterface $attribute */ $attribute = DataFixtureStorageManager::getStorage()->get('attribute'); /** @var AttributeOptionInterface $option1 */ $option1 = DataFixtureStorageManager::getStorage()->get('option1'); /** @var AttributeOptionInterface $option2 */ $option2 = DataFixtureStorageManager::getStorage()->get('option2'); /** @var AttributeOptionInterface $option3 */ $option3 = DataFixtureStorageManager::getStorage()->get('option3'); $result = $this->graphQlQuery(sprintf(self::QUERY, $attribute->getAttributeCode(), 'customer')); $this->assertEquals( [ 'customAttributeMetadataV2' => [ 'items' => [ [ 'code' => $attribute->getAttributeCode(), 'default_value' => $option3->getValue() . ',' . $option2->getValue(), 'options' => [ $this->getOptionData($option1), $this->getOptionData($option2), $this->getOptionData($option3) ] ] ], 'errors' => [] ] ], $result ); $this->assertEquals($option2->getIsDefault(), true); $this->assertEquals($option3->getIsDefault(), true); } /** * @param AttributeOptionInterface $option * @return array */ private function getOptionData(AttributeOptionInterface $option): array { return [ 'label' => $option->getLabel(), 'value' => $option->getValue(), 'is_default' => $option->getIsDefault() ]; } }