You are here

protected function MediaMigrationAssertionsBaseTrait::assertArticleBodyFieldMigrationProcesses in Media Migration 8

Tests the processes of the body field of the given article migration.

Parameters

string $article_node_migration_id: The ID of the node migration plugin instance.

array|string|null $body_migration_process: The expected process(es) of the body field.

Throws

\PHPUnit\Framework\ExpectationFailedException

6 calls to MediaMigrationAssertionsBaseTrait::assertArticleBodyFieldMigrationProcesses()
DrushWithCoreMigrationsFromFileTest::testMigrationWithDrush in tests/src/Functional/DrushWithCoreMigrationsFromFileTest.php
Test migrations provided by core Migrate API with Drush and Migrate Tools.
DrushWithCoreMigrationsFromMediaTest::testMigrationWithDrush in tests/src/Functional/DrushWithCoreMigrationsFromMediaTest.php
Test media migrations with Drush and Migrate Tools.
DrushWithMigrateUpgradeFromFileTest::testMigrationWithDrush in tests/src/Functional/DrushWithMigrateUpgradeFromFileTest.php
Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
DrushWithMigrateUpgradeFromMediaTest::testMigrationWithDrush in tests/src/Functional/DrushWithMigrateUpgradeFromMediaTest.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.

... See full list

File

tests/src/Traits/MediaMigrationAssertionsBaseTrait.php, line 721

Class

MediaMigrationAssertionsBaseTrait
Trait for media migration tests.

Namespace

Drupal\Tests\media_migration\Traits

Code

protected function assertArticleBodyFieldMigrationProcesses(string $article_node_migration_id, $body_migration_process = NULL) {
  $migration_plugin_manager = $this->container
    ->get('plugin.manager.migration');
  assert($migration_plugin_manager instanceof MigrationPluginManagerInterface);
  try {
    $article_migration = $migration_plugin_manager
      ->getDefinition($article_node_migration_id);
  } catch (PluginException $e) {
    throw new ExpectationFailedException(sprintf("The article node migration with the given ID '%s' does not exist.", $article_node_migration_id));
  }
  $migration_process = $body_migration_process ?? [
    [
      'plugin' => 'get',
      'source' => 'body',
    ],
    [
      'plugin' => 'media_wysiwyg_filter',
    ],
    [
      'plugin' => 'img_tag_to_embed',
    ],
  ];
  $this
    ->assertEquals($migration_process, $article_migration['process']['body'], sprintf("Article node's body field has different migration processes than expected: %s", Variable::export($article_migration['process']['body'])));
}