function MigrateProcessErrorMessagesTest::testSubProcessErrorMessage

Same name and namespace in other branches
  1. 11.x core/modules/migrate/tests/src/Kernel/MigrateProcessErrorMessagesTest.php \Drupal\Tests\migrate\Kernel\MigrateProcessErrorMessagesTest::testSubProcessErrorMessage()

Tests format of map messages saved from sub_process exceptions.

This checks the format of messages that are thrown from normal process plugins while being executed inside a sub_process pipeline as they bubble up to the main migration.

File

core/modules/migrate/tests/src/Kernel/MigrateProcessErrorMessagesTest.php, line 122

Class

MigrateProcessErrorMessagesTest
Tests the format of messages from process plugin exceptions.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testSubProcessErrorMessage() : void {
  $this->definition['process']['subprocess_error'] = [
    'plugin' => 'sub_process',
    'source' => 'my_property',
    'process' => [
      'subfield' => [
        [
          'plugin' => 'test_error',
          'value' => 'subfield',
        ],
      ],
    ],
  ];
  $this->processPluginManager
    ->createInstance('sub_process', Argument::cetera())
    ->will(fn($x) => new SubProcess($x[1], 'sub_process', [
    'handle_multiples' => TRUE,
  ]));
  $this->idMap
    ->saveMessage([
    'id' => 1,
  ], "process_errors_migration:subprocess_error:sub_process: test_error: Process exception.", MigrationInterface::MESSAGE_ERROR)
    ->shouldBeCalled();
  $this->setPluginManagers();
  /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
  $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($this->definition);
  $executable = new MigrateExecutable($migration, $this);
  $executable->import();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.