You are here

protected function MediaMigrationAssertionsForMediaSourceTrait::assertMedia10FieldValues in Media Migration 8

Assertions of media 10 ("yellow.webp").

5 calls to MediaMigrationAssertionsForMediaSourceTrait::assertMedia10FieldValues()
DrushWithCoreMigrationsFromMediaTest::testAllMigrationWithDrush in tests/src/Functional/DrushWithCoreMigrationsFromMediaTest.php
Test all migrations with Drush and Migrate Tools.
DrushWithCoreMigrationsFromMediaTest::testMigrationWithDrush in tests/src/Functional/DrushWithCoreMigrationsFromMediaTest.php
Test media migrations with Drush and Migrate Tools.
DrushWithMigrateUpgradeFromMediaTest::testMigrationWithDrush in tests/src/Functional/DrushWithMigrateUpgradeFromMediaTest.php
Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
MediaMigrationTest::testMediaMigration in tests/src/Kernel/Migrate/MediaMigrationTest.php
Tests the migration of media entities.
MigrateMediaTest::testMediaMigrate in tests/src/Functional/MigrateMediaTest.php
Tests the result of the media migration.

File

tests/src/Traits/MediaMigrationAssertionsForMediaSourceTrait.php, line 301

Class

MediaMigrationAssertionsForMediaSourceTrait
Trait for media migration tests.

Namespace

Drupal\Tests\media_migration\Traits

Code

protected function assertMedia10FieldValues() {
  $media = $this->container
    ->get('entity_type.manager')
    ->getStorage('media')
    ->load(10);
  assert($media instanceof MediaInterface);
  $this
    ->assertEquals([
    'mid' => [
      [
        'value' => '10',
      ],
    ],
    'bundle' => [
      [
        'target_id' => 'image',
      ],
    ],
    'name' => [
      [
        'value' => 'yellow.webp',
      ],
    ],
    'uid' => [
      [
        'target_id' => '2',
      ],
    ],
    'status' => [
      [
        'value' => '1',
      ],
    ],
    'created' => [
      [
        'value' => '1594191582',
      ],
    ],
    'field_media_image' => [
      [
        'target_id' => '10',
        'alt' => 'Alternative text about yellow.webp',
        'title' => 'Title copy for yellow.webp',
        'width' => '640',
        'height' => '400',
      ],
    ],
    'field_media_integer' => [],
  ], $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()));
}