You are here

public function MediaMigrationPlainTest::testChangeTracking in Media Migration 8

Tests media entity migration with change tracking enabled.

File

tests/src/Kernel/Migrate/MediaMigrationPlainTest.php, line 116

Class

MediaMigrationPlainTest
Tests media migration from non-media source.

Namespace

Drupal\Tests\media_migration\Kernel\Migrate

Code

public function testChangeTracking() {
  $module_installer = \Drupal::service('module_installer');
  assert($module_installer instanceof ModuleInstallerInterface);
  $module_installer
    ->install([
    'media_migration_test_change_tracking',
  ]);
  $this
    ->testPlainFileToMediaMigration(FALSE, FALSE);

  // Update file with ID 1 (BLUE png).
  $this->sourceDatabase
    ->update('file_managed')
    ->condition('fid', 1)
    ->fields([
    'filename' => 'Blue PNG changed',
  ])
    ->execute();

  // To get clever failure on PHPUnit 9, we need this.
  // @see https://drupal.org/i/3197324
  try {
    $this
      ->executeMediaMigrations();
  } catch (\Exception $exception) {
    throw new AssertionFailedError($exception
      ->getMessage() . "\n" . $exception
      ->getLine() . "\n" . $exception
      ->getTraceAsString());
  }
  $this
    ->assertNonMediaToMedia1FieldValues('Blue PNG changed');
}