function MigrateProcessErrorMessagesTest::setPluginManagers

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

Prepares and sets the prophesized plugin managers.

2 calls to MigrateProcessErrorMessagesTest::setPluginManagers()
MigrateProcessErrorMessagesTest::testProcessErrorMessage in core/modules/migrate/tests/src/Kernel/MigrateProcessErrorMessagesTest.php
Tests format of map messages saved from plugin exceptions.
MigrateProcessErrorMessagesTest::testSubProcessErrorMessage in core/modules/migrate/tests/src/Kernel/MigrateProcessErrorMessagesTest.php
Tests format of map messages saved from sub_process exceptions.

File

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

Class

MigrateProcessErrorMessagesTest
Tests the format of messages from process plugin exceptions.

Namespace

Drupal\Tests\migrate\Kernel

Code

protected function setPluginManagers() {
  $error_plugin_prophecy = $this->prophesize(MigrateProcessInterface::class);
  $error_plugin_prophecy->getPluginDefinition()
    ->willReturn([
    'plugin_id' => 'test_error',
  ]);
  $error_plugin_prophecy->getPluginId()
    ->willReturn('test_error');
  $error_plugin_prophecy->reset()
    ->shouldBeCalled();
  $error_plugin_prophecy->transform(Argument::cetera())
    ->willThrow(new MigrateException('Process exception.'));
  $this->processPluginManager
    ->createInstance('get', Argument::cetera())
    ->will(fn($x) => new Get($x[1], 'get', [
    'handle_multiples' => TRUE,
  ]));
  $this->processPluginManager
    ->createInstance('test_error', Argument::cetera())
    ->willReturn($error_plugin_prophecy->reveal());
  $this->idMap
    ->setMessage(Argument::any())
    ->willReturn();
  $this->idMap
    ->getRowBySource(Argument::any())
    ->willReturn([]);
  $this->idMap
    ->delete(Argument::cetera())
    ->willReturn();
  $this->idMap
    ->saveIdMapping(Argument::cetera())
    ->willReturn();
  $this->idMapPluginManager
    ->createInstance('idmap_prophecy', Argument::cetera())
    ->willReturn($this->idMap
    ->reveal());
  $this->container
    ->set('plugin.manager.migrate.process', $this->processPluginManager
    ->reveal());
  $this->container
    ->set('plugin.manager.migrate.id_map', $this->idMapPluginManager
    ->reveal());
}

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