You are here

protected function MediaMigrationAssertionsForNonMediaSourceTrait::assertNonMediaToMedia1FieldValues in Media Migration 8

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

6 calls to MediaMigrationAssertionsForNonMediaSourceTrait::assertNonMediaToMedia1FieldValues()
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::testChangeTracking in tests/src/Kernel/Migrate/MediaMigrationPlainTest.php
Tests media entity migration with change tracking enabled.
MediaMigrationPlainTest::testPlainFileToMediaMigration in tests/src/Kernel/Migrate/MediaMigrationPlainTest.php
Tests the migration of plain file and image fields to media reference.

... See full list

File

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

Class

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

Namespace

Drupal\Tests\media_migration\Traits

Code

protected function assertNonMediaToMedia1FieldValues($name = 'blue.png') {
  $media = $this->container
    ->get('entity_type.manager')
    ->getStorage('media')
    ->load(1);
  assert($media instanceof MediaInterface);
  $this
    ->assertEquals([
    'mid' => [
      [
        'value' => '1',
      ],
    ],
    'bundle' => [
      [
        'target_id' => 'image',
      ],
    ],
    'name' => [
      [
        'value' => $name,
      ],
    ],
    'uid' => [
      [
        'target_id' => '2',
      ],
    ],
    'status' => [
      [
        'value' => '1',
      ],
    ],
    'created' => [
      [
        'value' => '1594368799',
      ],
    ],
    'field_media_image' => [
      [
        'target_id' => '1',
        'alt' => 'Alt for blue.png',
        'title' => NULL,
        'width' => '1280',
        'height' => '720',
      ],
    ],
  ], $this
    ->getImportantEntityProperties($media));

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

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