Skip to content

Commit 1faa43b

Browse files
ENGCOM-5272: Product media_gallery_entries / types only present if image, thumbnai… #718
- Merge Pull Request magento/graphql-ce#718 from XxXgeoXxX/graphql-ce:2.3-develop##612 - Merged commits: 1. bb5ae76 2. b776ec3 3. f01d084 4. 44d7ff4
2 parents fdfaed6 + 44d7ff4 commit 1faa43b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
use Magento\TestFramework\TestCase\GraphQlAbstract;
1111

12+
/**
13+
* Test cases for product media gallery data retrieval.
14+
*/
1215
class MediaGalleryTest extends GraphQlAbstract
1316
{
1417
/**
@@ -45,19 +48,48 @@ public function testProductSmallImageUrlWithExistingImage()
4548
self::assertTrue($this->checkImageExists($response['products']['items'][0]['small_image']['url']));
4649
}
4750

51+
/**
52+
* @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php
53+
*/
54+
public function testProductMediaGalleryEntries()
55+
{
56+
$this->markTestSkipped('https://github.com/magento/graphql-ce/issues/738');
57+
$productSku = 'simple';
58+
$query = <<<QUERY
59+
{
60+
products(filter: {sku: {eq: "{$productSku}"}}) {
61+
items {
62+
name
63+
sku
64+
media_gallery_entries {
65+
id
66+
file
67+
types
68+
}
69+
}
70+
}
71+
}
72+
QUERY;
73+
$response = $this->graphQlQuery($query);
74+
75+
self::assertArrayHasKey('file', $response['products']['items'][0]['media_gallery_entries'][0]);
76+
self::assertContains('magento_image.jpg', $response['products']['items'][0]['media_gallery_entries'][0]['url']);
77+
}
78+
4879
/**
4980
* @param string $url
5081
* @return bool
5182
*/
5283
private function checkImageExists(string $url): bool
5384
{
85+
// phpcs:disable Magento2.Functions.DiscouragedFunction
5486
$connection = curl_init($url);
5587
curl_setopt($connection, CURLOPT_HEADER, true);
5688
curl_setopt($connection, CURLOPT_NOBODY, true);
5789
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
5890
curl_exec($connection);
5991
$responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE);
60-
92+
// phpcs:enable Magento2.Functions.DiscouragedFunction
6193
return $responseStatus === 200 ? true : false;
6294
}
6395
}

0 commit comments

Comments
 (0)