Skip to content

Commit 9d358d4

Browse files
committed
PWA-1720: Expose storefront properties of Catalog attributes
- fix existing tests
1 parent d59d22e commit 9d358d4

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductAttributeTypeTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function testAttributeTypeResolver()
7373
];
7474
$attributeTypes = ['String', 'Int', 'Float','Boolean', 'Float'];
7575
$inputTypes = ['textarea', 'select', 'price', 'boolean', 'price'];
76+
7677
$this->assertAttributeType($attributeTypes, $expectedAttributeCodes, $entityType, $inputTypes, $response);
7778
}
7879

@@ -173,7 +174,7 @@ public function testComplexAttributeTypeResolver()
173174
'text',
174175
'gallery'
175176
];
176-
$this->assertAttributeType($attributeTypes, $expectedAttributeCodes, $entityTypes, $inputTypes, $response);
177+
$this->assertComplexAttributeType($attributeTypes, $expectedAttributeCodes, $entityTypes, $inputTypes, $response);
177178
}
178179

179180
/**
@@ -236,7 +237,7 @@ public function testUnDefinedAttributeType()
236237
* @param array $actualResponse
237238
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
238239
*/
239-
private function assertAttributeType(
240+
private function assertComplexAttributeType(
240241
$attributeTypes,
241242
$expectedAttributeCodes,
242243
$entityTypes,
@@ -283,4 +284,34 @@ private function assertAttributeType(
283284

284285
}
285286
}
287+
288+
/**
289+
* @param array $attributeTypes
290+
* @param array $expectedAttributeCodes
291+
* @param array $entityTypes
292+
* @param array $inputTypes
293+
* @param array $actualResponse
294+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
295+
*/
296+
private function assertAttributeType(
297+
$attributeTypes,
298+
$expectedAttributeCodes,
299+
$entityTypes,
300+
$inputTypes,
301+
$actualResponse
302+
) {
303+
$attributeMetaDataItems = array_map(null, $actualResponse['customAttributeMetadata']['items'], $attributeTypes);
304+
305+
foreach ($attributeMetaDataItems as $itemIndex => $itemArray) {
306+
$this->assertResponseFields(
307+
$attributeMetaDataItems[$itemIndex][0],
308+
[
309+
"attribute_code" => $expectedAttributeCodes[$itemIndex],
310+
"attribute_type" => $attributeTypes[$itemIndex],
311+
"entity_type" => $entityTypes[$itemIndex],
312+
"input_type" => $inputTypes[$itemIndex]
313+
]
314+
);
315+
}
316+
}
286317
}

0 commit comments

Comments
 (0)