@@ -381,6 +381,97 @@ public function testCreate($product)
381
381
$ this ->deleteProduct ($ product [ProductInterface::SKU ]);
382
382
}
383
383
384
+ /**
385
+ * Media gallery entries with external videos
386
+ *
387
+ * @return array
388
+ */
389
+ public function externalVideoDataProvider (): array
390
+ {
391
+ return [
392
+ [
393
+ [
394
+ [
395
+ 'media_type ' => 'external-video ' ,
396
+ 'disabled ' => false ,
397
+ 'label ' => 'Test Video Created ' ,
398
+ 'types ' => [],
399
+ 'position ' => 1 ,
400
+ 'content ' => [
401
+ 'type ' => 'image/png ' ,
402
+ 'name ' => 'thumbnail.png ' ,
403
+ 'base64_encoded_data ' => 'iVBORw0KGgoAAAANSUhEUgAAAP8AAADGCAMAAAAqo6adAAAAA1BMVEUAAP79f '
404
+ . '+LBAAAASElEQVR4nO3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA '
405
+ . 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAA+BsYAAAF7hZJ0AAAAAElFTkSuQmCC ' ,
406
+ ],
407
+ 'extension_attributes ' => [
408
+ 'video_content ' => [
409
+ 'media_type ' => 'external-video ' ,
410
+ 'video_provider ' => 'youtube ' ,
411
+ 'video_url ' => 'https://www.youtube.com/ ' ,
412
+ 'video_title ' => 'Video title ' ,
413
+ 'video_description ' => 'Video description ' ,
414
+ 'video_metadata ' => 'Video meta ' ,
415
+ ],
416
+ ],
417
+ ]
418
+ ]
419
+ ],
420
+ [
421
+ [
422
+ [
423
+ 'media_type ' => 'external-video ' ,
424
+ 'disabled ' => false ,
425
+ 'label ' => 'Test Video Updated ' ,
426
+ 'types ' => [],
427
+ 'position ' => 1 ,
428
+ 'content ' => [
429
+ 'type ' => 'image/png ' ,
430
+ 'name ' => 'thumbnail.png ' ,
431
+ 'base64_encoded_data ' => 'iVBORw0KGgoAAAANSUhEUgAAAP8AAADGCAMAAAAqo6adAAAAA1BMVEUAAP79f '
432
+ . '+LBAAAASElEQVR4nO3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA '
433
+ . 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAA+BsYAAAF7hZJ0AAAAAElFTkSuQmCC ' ,
434
+ ],
435
+ 'extension_attributes ' => [
436
+ 'video_content ' => [
437
+ 'media_type ' => 'external-video ' ,
438
+ 'video_provider ' => 'vimeo ' ,
439
+ 'video_url ' => 'https://www.vimeo.com/ ' ,
440
+ 'video_title ' => 'Video title ' ,
441
+ 'video_description ' => 'Video description ' ,
442
+ 'video_metadata ' => 'Video meta ' ,
443
+ ],
444
+ ],
445
+ ]
446
+ ]
447
+ ]
448
+ ];
449
+ }
450
+
451
+ /**
452
+ * Test create/ update product with external video media gallery entry
453
+ *
454
+ * @dataProvider externalVideoDataProvider
455
+ * @param array $mediaGalleryData
456
+ */
457
+ public function testCreateWithExternalVideo (array $ mediaGalleryData )
458
+ {
459
+ $ simpleProductBaseData = $ this ->getSimpleProductData (
460
+ [
461
+ ProductInterface::NAME => 'Product With Ext. Video ' ,
462
+ ProductInterface::SKU => 'prod-with-ext-video '
463
+ ]
464
+ );
465
+
466
+ $ simpleProductBaseData ['media_gallery_entries ' ] = $ mediaGalleryData ;
467
+
468
+ $ response = $ this ->saveProduct ($ simpleProductBaseData );
469
+ $ this ->assertEquals (
470
+ $ simpleProductBaseData ['media_gallery_entries ' ][0 ]['extension_attributes ' ],
471
+ $ response ["media_gallery_entries " ][0 ]["extension_attributes " ]
472
+ );
473
+ }
474
+
384
475
/**
385
476
* @param array $fixtureProduct
386
477
*
0 commit comments