Skip to content

Commit 73bb83c

Browse files
author
Prabhu Ram
committed
MC-18510: API functional test
- Added api functional test
1 parent ef4f96a commit 73bb83c

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,78 @@ public function testMediaGalleryTypesAreCorrect()
8282
$this->assertEquals(['thumbnail', 'swatch_image'], $mediaGallery[1]['types']);
8383
}
8484

85+
/**
86+
* @magentoApiDataFixture Magento/Catalog/_files/product_with_multiple_images.php
87+
*/
88+
public function testMediaGallery()
89+
{
90+
$productSku = 'simple';
91+
$query = <<<QUERY
92+
{
93+
products(filter: {sku: {eq: "{$productSku}"}}) {
94+
items {
95+
media_gallery {
96+
label
97+
url
98+
}
99+
}
100+
}
101+
}
102+
QUERY;
103+
$response = $this->graphQlQuery($query);
104+
$this->assertNotEmpty($response['products']['items'][0]['media_gallery']);
105+
$mediaGallery = $response['products']['items'][0]['media_gallery'];
106+
$this->assertCount(2, $mediaGallery);
107+
$this->assertEquals('Image Alt Text', $mediaGallery[0]['label']);
108+
self::assertTrue($this->checkImageExists($mediaGallery[0]['url']));
109+
$this->assertEquals('Thumbnail Image', $mediaGallery[1]['label']);
110+
self::assertTrue($this->checkImageExists($mediaGallery[1]['url']));
111+
}
112+
113+
/**
114+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_media_gallery_entries.php
115+
*/
116+
public function testMediaGalleryForProductVideos()
117+
{
118+
$productSku = 'simple';
119+
$query = <<<QUERY
120+
{
121+
products(filter: {sku: {eq: "{$productSku}"}}) {
122+
items {
123+
media_gallery {
124+
label
125+
url
126+
... on ProductVideo {
127+
video_content {
128+
media_type
129+
video_provider
130+
video_url
131+
video_title
132+
video_description
133+
video_metadata
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}
140+
QUERY;
141+
$response = $this->graphQlQuery($query);
142+
$this->assertNotEmpty($response['products']['items'][0]['media_gallery']);
143+
$mediaGallery = $response['products']['items'][0]['media_gallery'];
144+
$this->assertCount(1, $mediaGallery);
145+
$this->assertEquals('Video Label', $mediaGallery[0]['label']);
146+
self::assertTrue($this->checkImageExists($mediaGallery[0]['url']));
147+
$this->assertNotEmpty($mediaGallery[0]['video_content']);
148+
$video_content = $mediaGallery[0]['video_content'];
149+
$this->assertEquals('external-video', $video_content['media_type']);
150+
$this->assertEquals('youtube', $video_content['video_provider']);
151+
$this->assertEquals('http://www.youtube.com/v/tH_2PFNmWoga', $video_content['video_url']);
152+
$this->assertEquals('Video title', $video_content['video_title']);
153+
$this->assertEquals('Video description', $video_content['video_description']);
154+
$this->assertEquals('Video Metadata', $video_content['video_metadata']);
155+
}
156+
85157
/**
86158
* @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php
87159
*/

0 commit comments

Comments
 (0)