You are here

protected function MediaMigrationAssertionsForNonMediaSourceTrait::assertNonMediaToMedia8FieldValues in Media Migration 8

Asserts the migration result from file ID 8 to media 8.

5 calls to MediaMigrationAssertionsForNonMediaSourceTrait::assertNonMediaToMedia8FieldValues()
DrushWithCoreMigrationsFromFileTest::testAllMigrationWithDrush in tests/src/Functional/DrushWithCoreMigrationsFromFileTest.php
Test all migrations with Drush and Migrate Tools.
DrushWithCoreMigrationsFromFileTest::testMigrationWithDrush in tests/src/Functional/DrushWithCoreMigrationsFromFileTest.php
Test migrations provided by core Migrate API with Drush and Migrate Tools.
DrushWithMigrateUpgradeFromFileTest::testMigrationWithDrush in tests/src/Functional/DrushWithMigrateUpgradeFromFileTest.php
Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
MediaMigrationPlainTest::testPlainFileToMediaMigration in tests/src/Kernel/Migrate/MediaMigrationPlainTest.php
Tests the migration of plain file and image fields to media reference.
MigrateMediaFromNonMediaSourceTest::testPlainFileToMediaMigration in tests/src/Functional/MigrateMediaFromNonMediaSourceTest.php
Tests the result of the media migration.

File

tests/src/Traits/MediaMigrationAssertionsForNonMediaSourceTrait.php, line 184

Class

MediaMigrationAssertionsForNonMediaSourceTrait
Trait for non-media source to media migration tests.

Namespace

Drupal\Tests\media_migration\Traits

Code

protected function assertNonMediaToMedia8FieldValues() {
  $media = $this->container
    ->get('entity_type.manager')
    ->getStorage('media')
    ->load(8);
  assert($media instanceof MediaInterface);
  $this
    ->assertEquals([
    'mid' => [
      [
        'value' => '8',
      ],
    ],
    'bundle' => [
      [
        'target_id' => 'video',
      ],
    ],
    'name' => [
      [
        'value' => 'video.webm',
      ],
    ],
    'uid' => [
      [
        'target_id' => '1',
      ],
    ],
    'status' => [
      [
        'value' => '1',
      ],
    ],
    'created' => [
      [
        'value' => '1597409263',
      ],
    ],
    'field_media_video_file' => [
      [
        'target_id' => '8',
        'display' => '1',
        'description' => NULL,
      ],
    ],
  ], $this
    ->getImportantEntityProperties($media));

  // Check the media field.
  $media_field = $this
    ->getReferencedEntities($media, 'field_media_video_file', 1);
  assert($media_field[0] instanceof FileInterface);

  // The referenced file should exist.
  $this
    ->assertTrue(file_exists($media_field[0]
    ->getFileUri()));
}