You are here

public function FieldDiscoveryTestTrait::assertFieldProcess in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/tests/src/Traits/FieldDiscoveryTestTrait.php \Drupal\Tests\migrate_drupal\Traits\FieldDiscoveryTestTrait::assertFieldProcess()
  2. 9 core/modules/migrate_drupal/tests/src/Traits/FieldDiscoveryTestTrait.php \Drupal\Tests\migrate_drupal\Traits\FieldDiscoveryTestTrait::assertFieldProcess()

Asserts the field discovery returns the expected processes.

Parameters

\Drupal\migrate_drupal\FieldDiscoveryInterface $field_discovery: The Field Discovery service.

\Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager: The migration plugin manager service.

string $core: The Drupal core version, either '6', or '7'.

string $field_plugin_method: (optional) The field plugin method to use.

array $expected_process: (optional) The expected resulting process.

string $entity_type_id: (optional) The entity type id.

string $bundle: (optional) The bundle.

2 calls to FieldDiscoveryTestTrait::assertFieldProcess()
FieldDiscoveryTest::testAddAllFieldProcessesAlters in core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php
Tests the addAllFieldProcesses method for field migrations.
FieldDiscoveryTest::testAddAllFieldProcessesAlters in core/modules/migrate_drupal/tests/src/Kernel/d7/FieldDiscoveryTest.php
Tests the addAllFieldProcesses method for field migrations.

File

core/modules/migrate_drupal/tests/src/Traits/FieldDiscoveryTestTrait.php, line 32

Class

FieldDiscoveryTestTrait
Helper functions to test field discovery.

Namespace

Drupal\Tests\migrate_drupal\Traits

Code

public function assertFieldProcess(FieldDiscoveryInterface $field_discovery, MigrationPluginManagerInterface $migration_plugin_manager, $core, $field_plugin_method = NULL, array $expected_process = [], $entity_type_id = NULL, $bundle = NULL) {
  $definition = [
    'migration_tags' => [
      'Drupal ' . $core,
    ],
    'field_plugin_method' => $field_plugin_method,
  ];
  $migration = $migration_plugin_manager
    ->createStubMigration($definition);
  if ($bundle) {
    $field_discovery
      ->addBundleFieldProcesses($migration, $entity_type_id, $bundle);
  }
  elseif ($entity_type_id) {
    $field_discovery
      ->addEntityFieldProcesses($migration, $entity_type_id);
  }
  else {
    $field_discovery
      ->addAllFieldProcesses($migration);
  }
  $actual_process = $migration
    ->getProcess();
  $this
    ->assertSame($expected_process, $actual_process);
}