You are here

protected function MediaMigrationAssertionsForMediaSourceTrait::assertMedia7FieldValues in Media Migration 8

Assertions of media 7.

"yellow.jpg"'s' alt and title properties should be empty, as well as its integer field.

6 calls to MediaMigrationAssertionsForMediaSourceTrait::assertMedia7FieldValues()
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.
MediaMigrationWithoutImageTitleTest::testMediaWithoutImageTitleMigration in tests/src/Kernel/Migrate/MediaMigrationWithoutImageTitleTest.php
Tests the migration of media entities without image title.

... See full list

File

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

Class

MediaMigrationAssertionsForMediaSourceTrait
Trait for media migration tests.

Namespace

Drupal\Tests\media_migration\Traits

Code

protected function assertMedia7FieldValues() {
  $media7 = $this->container
    ->get('entity_type.manager')
    ->getStorage('media')
    ->load(7);
  assert($media7 instanceof MediaInterface);
  $this
    ->assertEquals('yellow.jpg', $media7
    ->label());
  $this
    ->assertEquals('image', $media7
    ->bundle());

  // Check 'field media image' field.
  $media7_image = $this
    ->getReferencedEntities($media7, 'field_media_image', 1);
  assert($media7_image[0] instanceof FileInterface);
  $this
    ->assertEquals('7', $media7_image[0]
    ->id());
  $this
    ->assertEquals('7', $media7->field_media_image->target_id);

  // Alt, title and integer must be empty.
  $this
    ->assertEquals('', $media7->field_media_image->alt);
  $this
    ->assertEquals('', $media7->field_media_image->title);
  $this
    ->assertEquals('', $media7->field_media_integer->value);

  // The following fields should not be present.
  $this
    ->assertFalse($media7
    ->hasField('field_file_image_alt_text'));
  $this
    ->assertFalse($media7
    ->hasField('field_file_image_title_text'));

  // Author should be user 2.
  $this
    ->assertEquals('2', $media7
    ->getOwnerId());

  // Assert authored on date.
  $this
    ->assertEquals('1588600435', $media7
    ->getCreatedTime());

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