19
19
/**
20
20
* Test EAV attributes metadata retrieval for entity type via GraphQL API
21
21
*/
22
+ #[
23
+ DataFixture(
24
+ Attribute::class,
25
+ [
26
+ 'entity_type_id ' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER ,
27
+ 'frontend_input ' => 'boolean ' ,
28
+ 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
29
+ ],
30
+ 'customerAttribute0 '
31
+ ),
32
+ DataFixture(
33
+ Attribute::class,
34
+ [
35
+ 'entity_type_id ' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER ,
36
+ 'frontend_input ' => 'boolean ' ,
37
+ 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
38
+ ],
39
+ 'customerAttribute1 '
40
+ ),
41
+ DataFixture(
42
+ Attribute::class,
43
+ [
44
+ 'entity_type_id ' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER ,
45
+ 'frontend_input ' => 'boolean ' ,
46
+ 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
47
+ ],
48
+ 'customerAttribute2 '
49
+ ),
50
+ DataFixture(
51
+ Attribute::class,
52
+ [
53
+ 'entity_type_id ' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID ,
54
+ 'frontend_input ' => 'boolean ' ,
55
+ 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
56
+ ],
57
+ 'catalogAttribute3 '
58
+ ),
59
+ DataFixture(
60
+ Attribute::class,
61
+ [
62
+ 'entity_type_id ' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID ,
63
+ 'frontend_input ' => 'boolean ' ,
64
+ 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
65
+ ],
66
+ 'catalogAttribute4 '
67
+ ),
68
+ DataFixture(
69
+ Attribute::class,
70
+ [
71
+ 'entity_type_id ' => SalesSetup::CREDITMEMO_PRODUCT_ENTITY_TYPE_ID ,
72
+ 'frontend_input ' => 'boolean ' ,
73
+ 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
74
+ ],
75
+ 'creditmemoAttribute5 '
76
+ )
77
+ ]
22
78
class AttributesListTest extends GraphQlAbstract
23
79
{
24
80
private const ATTRIBUTE_NOT_FOUND_ERROR = "Attribute was not found in query result " ;
25
81
26
- #[
27
- DataFixture(
28
- Attribute::class,
29
- [
30
- 'entity_type_id ' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER ,
31
- 'frontend_input ' => 'boolean ' ,
32
- 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
33
- ],
34
- 'attribute0 '
35
- ),
36
- DataFixture(
37
- Attribute::class,
38
- [
39
- 'entity_type_id ' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER ,
40
- 'frontend_input ' => 'boolean ' ,
41
- 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
42
- ],
43
- 'attribute1 '
44
- ),
45
- DataFixture(
46
- Attribute::class,
47
- [
48
- 'entity_type_id ' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER ,
49
- 'frontend_input ' => 'boolean ' ,
50
- 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
51
- ],
52
- 'attribute2 '
53
- ),
54
- DataFixture(
55
- Attribute::class,
56
- [
57
- 'entity_type_id ' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID ,
58
- 'frontend_input ' => 'boolean ' ,
59
- 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
60
- ],
61
- 'attribute3 '
62
- ),
63
- DataFixture(
64
- Attribute::class,
65
- [
66
- 'entity_type_id ' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID ,
67
- 'frontend_input ' => 'boolean ' ,
68
- 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
69
- ],
70
- 'attribute4 '
71
- ),
72
- DataFixture(
73
- Attribute::class,
74
- [
75
- 'entity_type_id ' => SalesSetup::CREDITMEMO_PRODUCT_ENTITY_TYPE_ID ,
76
- 'frontend_input ' => 'boolean ' ,
77
- 'source_model ' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean '
78
- ],
79
- 'attribute5 '
80
- )
81
- ]
82
- public function testAttributesList (): void
82
+
83
+ public function testAttributesListForCustomerEntityType (): void
83
84
{
84
85
$ queryResult = $ this ->graphQlQuery (<<<QRY
85
86
{
@@ -100,36 +101,39 @@ public function testAttributesList(): void
100
101
$ this ->assertGreaterThanOrEqual (3 , count ($ queryResult ['attributesList ' ]['items ' ]));
101
102
102
103
/** @var AttributeInterface $attribute */
103
- $ attribute5 = DataFixtureStorageManager::getStorage ()->get ('attribute5 ' );
104
+ $ creditmemoAttribute5 = DataFixtureStorageManager::getStorage ()->get ('creditmemoAttribute5 ' );
104
105
105
106
/** @var AttributeInterface $attribute */
106
- $ attribute0 = DataFixtureStorageManager::getStorage ()->get ('attribute0 ' );
107
+ $ customerAttribute0 = DataFixtureStorageManager::getStorage ()->get ('customerAttribute0 ' );
107
108
/** @var AttributeInterface $attribute */
108
- $ attribute1 = DataFixtureStorageManager::getStorage ()->get ('attribute1 ' );
109
+ $ customerAttribute1 = DataFixtureStorageManager::getStorage ()->get ('customerAttribute1 ' );
109
110
/** @var AttributeInterface $attribute */
110
- $ attribute2 = DataFixtureStorageManager::getStorage ()->get ('attribute2 ' );
111
+ $ customerAttribute2 = DataFixtureStorageManager::getStorage ()->get ('customerAttribute2 ' );
111
112
112
113
$ this ->assertEquals (
113
- $ attribute0 ->getAttributeCode (),
114
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute0 ->getAttributeCode ())['code ' ],
114
+ $ customerAttribute0 ->getAttributeCode (),
115
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ customerAttribute0 ->getAttributeCode ())['code ' ],
115
116
self ::ATTRIBUTE_NOT_FOUND_ERROR
116
117
);
117
118
118
119
$ this ->assertEquals (
119
- $ attribute1 ->getAttributeCode (),
120
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute1 ->getAttributeCode ())['code ' ],
120
+ $ customerAttribute1 ->getAttributeCode (),
121
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ customerAttribute1 ->getAttributeCode ())['code ' ],
121
122
self ::ATTRIBUTE_NOT_FOUND_ERROR
122
123
);
123
124
$ this ->assertEquals (
124
- $ attribute2 ->getAttributeCode (),
125
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute2 ->getAttributeCode ())['code ' ],
125
+ $ customerAttribute2 ->getAttributeCode (),
126
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ customerAttribute2 ->getAttributeCode ())['code ' ],
126
127
self ::ATTRIBUTE_NOT_FOUND_ERROR
127
128
);
128
129
$ this ->assertEquals (
129
130
[],
130
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute5 ->getAttributeCode ())
131
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ creditmemoAttribute5 ->getAttributeCode ())
131
132
);
133
+ }
132
134
135
+ public function testAttributesListForCatalogProductEntityType (): void
136
+ {
133
137
$ queryResult = $ this ->graphQlQuery (<<<QRY
134
138
{
135
139
attributesList(entityType: CATALOG_PRODUCT) {
@@ -148,23 +152,26 @@ public function testAttributesList(): void
148
152
$ this ->assertGreaterThanOrEqual (2 , count ($ queryResult ['attributesList ' ]['items ' ]));
149
153
150
154
/** @var AttributeInterface $attribute */
151
- $ attribute3 = DataFixtureStorageManager::getStorage ()->get ('attribute3 ' );
155
+ $ creditmemoAttribute5 = DataFixtureStorageManager::getStorage ()->get ('creditmemoAttribute5 ' );
156
+
157
+ /** @var AttributeInterface $attribute */
158
+ $ catalogAttribute3 = DataFixtureStorageManager::getStorage ()->get ('catalogAttribute3 ' );
152
159
/** @var AttributeInterface $attribute */
153
- $ attribute4 = DataFixtureStorageManager::getStorage ()->get ('attribute4 ' );
160
+ $ catalogAttribute4 = DataFixtureStorageManager::getStorage ()->get ('catalogAttribute4 ' );
154
161
155
162
$ this ->assertEquals (
156
- $ attribute3 ->getAttributeCode (),
157
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute3 ->getAttributeCode ())['code ' ],
163
+ $ catalogAttribute3 ->getAttributeCode (),
164
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ catalogAttribute3 ->getAttributeCode ())['code ' ],
158
165
self ::ATTRIBUTE_NOT_FOUND_ERROR
159
166
);
160
167
$ this ->assertEquals (
161
- $ attribute4 ->getAttributeCode (),
162
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute4 ->getAttributeCode ())['code ' ],
168
+ $ catalogAttribute4 ->getAttributeCode (),
169
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ catalogAttribute4 ->getAttributeCode ())['code ' ],
163
170
self ::ATTRIBUTE_NOT_FOUND_ERROR
164
171
);
165
172
$ this ->assertEquals (
166
173
[],
167
- $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ attribute5 ->getAttributeCode ())
174
+ $ this ->getAttributeByCode ($ queryResult ['attributesList ' ]['items ' ], $ creditmemoAttribute5 ->getAttributeCode ())
168
175
);
169
176
}
170
177
0 commit comments