X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fmodules%2Fvideo_embed_media%2Ftests%2Fsrc%2FFunctional%2FUpgradePathTest.php;fp=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fmodules%2Fvideo_embed_media%2Ftests%2Fsrc%2FFunctional%2FUpgradePathTest.php;h=52c4aa3d42bf3f42e18cdb724618fd8a7f637382;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/UpgradePathTest.php b/web/modules/contrib/video_embed_field/modules/video_embed_media/tests/src/Functional/UpgradePathTest.php new file mode 100644 index 000000000..52c4aa3d4 --- /dev/null +++ b/web/modules/contrib/video_embed_field/modules/video_embed_media/tests/src/Functional/UpgradePathTest.php @@ -0,0 +1,96 @@ +drupalLogin($this->createAdminUser()); + + // Create a media_entity_embeddable_video bundle and field. + $this->drupalGet('admin/structure/media/add'); + $this->submitForm([ + 'label' => 'embeddable Video Bundle', + 'id' => 'embeddable_bundle', + 'type' => 'embeddable_video', + ], 'Save media bundle'); + $this->assertSession()->pageTextContains('The media bundle embeddable Video Bundle has been added.'); + $this->drupalGet('admin/structure/media/manage/embeddable_bundle/fields/add-field'); + $this->submitForm([ + 'new_storage_type' => 'string', + 'label' => 'Video Text Field', + 'field_name' => 'video_text_field', + ], t('Save and continue')); + $this->submitForm([], t('Save field settings')); + $this->submitForm([], t('Save settings')); + $this->drupalGet('admin/structure/media/manage/embeddable_bundle'); + $this->submitForm(['type_configuration[embeddable_video][source_field]' => 'field_video_text_field'], t('Save media bundle')); + $this->drupalGet('media/add/embeddable_bundle'); + $this->submitForm([ + 'field_video_text_field[0][value]' => 'https://www.youtube.com/watch?v=gnERPdAiuSo', + 'name[0][value]' => 'Test Media Entity', + ], t('Save')); + + // Install video_embed_field. + $this->container->get('module_installer')->install(['video_embed_media'], TRUE); + + $this->assertUpgradeComplete(); + + // Uninstall the module and ensure everything is still okay. + $this->drupalGet('admin/modules/uninstall'); + $this->submitForm([ + 'uninstall[media_entity_embeddable_video]' => TRUE, + ], t('Uninstall')); + $this->submitForm([], 'Uninstall'); + + $this->assertUpgradeComplete(); + } + + /** + * Assert the upgrade was successful. + */ + protected function assertUpgradeComplete() { + // Ensure the new type is selected. + $this->drupalGet('admin/structure/media/manage/embeddable_bundle'); + $this->assertTrue(!empty($this->getSession()->getPage()->find('xpath', '//option[@value="video_embed_field" and @selected="selected"]')), 'The media type was updated.'); + // Ensure the media entity has updated values. + $this->drupalGet('media/1/edit'); + $this->assertEquals($this->getSession()->getPage()->find('css', 'input[name="field_video_text_field[0][value]"]')->getValue(), 'https://www.youtube.com/watch?v=gnERPdAiuSo', 'Field values were copied.'); + } + +}