@@ -82,6 +82,78 @@ public function testMediaGalleryTypesAreCorrect()
82
82
$ this ->assertEquals (['thumbnail ' , 'swatch_image ' ], $ mediaGallery [1 ]['types ' ]);
83
83
}
84
84
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
+
85
157
/**
86
158
* @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php
87
159
*/
0 commit comments