You are here

public function UpgradePathTest::testMediaBundleCreation in Video Embed Field 8

Test the upgrade path.

File

modules/video_embed_media/tests/src/Functional/UpgradePathTest.php, line 42

Class

UpgradePathTest
Test the upgrade path from media_entity_embedded_video.

Namespace

Drupal\Tests\video_embed_media\Functional

Code

public function testMediaBundleCreation() {
  $this
    ->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();
}