X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fmodules%2Fvideo_embed_media%2Ftests%2Fsrc%2FFunctional%2FBundleTest.php;fp=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fmodules%2Fvideo_embed_media%2Ftests%2Fsrc%2FFunctional%2FBundleTest.php;h=ef3403882a93075b85ff26ab9364f3f082a0ed40;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/video_embed_field/modules/video_embed_media/tests/src/Functional/BundleTest.php b/web/modules/contrib/video_embed_field/modules/video_embed_media/tests/src/Functional/BundleTest.php new file mode 100644 index 000000000..ef3403882 --- /dev/null +++ b/web/modules/contrib/video_embed_field/modules/video_embed_media/tests/src/Functional/BundleTest.php @@ -0,0 +1,89 @@ +drupalLogin($this->createAdminUser()); + + // Create a new media bundle. + $this->drupalGet('admin/structure/media/add'); + $this->submitForm([ + 'label' => 'Video Bundle', + 'id' => 'video_bundle', + 'type' => 'video_embed_field', + ], t('Save media bundle')); + $this->assertSession()->pageTextContains('The media bundle Video Bundle has been added.'); + + // Ensure the video field is added to the media entity. + $this->drupalGet('admin/structure/media/manage/video_bundle/fields'); + $this->assertSession()->pageTextContains('field_media_video_embed_field'); + $this->assertSession()->pageTextContains('Video URL'); + + // Add a media entity with the new field. + $this->drupalGet('media/add/video_bundle'); + $this->submitForm([ + 'name[0][value]' => 'Drupal video!', + 'field_media_video_embed_field[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', + ], 'Save'); + // We should see the video thumbnail on the media page. + $this->assertContains('video_thumbnails/XgYu7-DQjDQ.jpg', $this->getSession()->getPage()->getHtml()); + + // Add another field and change the configured media field. + $this->drupalGet('admin/structure/media/manage/video_bundle/fields/add-field'); + $this->submitForm([ + 'new_storage_type' => 'video_embed_field', + 'label' => 'New Video Field', + 'field_name' => 'new_video_field', + ], 'Save and continue'); + $this->submitForm([], t('Save field settings')); + $this->submitForm([], t('Save settings')); + + // Update video source field. + $this->drupalGet('admin/structure/media/manage/video_bundle'); + $this->submitForm([ + 'type_configuration[video_embed_field][source_field]' => 'field_new_video_field', + ], t('Save media bundle')); + + // Create a video, populating both video URL fields. + $this->drupalGet('media/add/video_bundle'); + $this->submitForm([ + 'name[0][value]' => 'Another Video!', + 'field_media_video_embed_field[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', + 'field_new_video_field[0][value]' => 'https://www.youtube.com/watch?v=gnERPdAiuSo', + ], t('Save')); + + // We should see the newly configured video thumbnail, but not the original. + $this->assertContains('video_thumbnails/gnERPdAiuSo.jpg', $this->getSession()->getPage()->getHtml()); + $this->assertNotContains('video_thumbnails/XgYu7-DQjDQ.jpg', $this->getSession()->getPage()->getHtml()); + } + +}