You are here

public function MenuLinkParentTest::testTransformException in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php \Drupal\Tests\migrate\Unit\process\MenuLinkParentTest::testTransformException()

Tests that an exception is thrown when the parent menu link is not found.

@dataProvider providerTransformException

Parameters

string[] $source_value: The source value(s) for the migration process plugin.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\migrate\MigrateException

\Drupal\migrate\MigrateSkipRowException

File

core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php, line 90

Class

MenuLinkParentTest
Tests the menu link parent process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformException(array $source_value) {
  [
    $parent_id,
    $menu_name,
  ] = $source_value;
  $this->migrateLookup
    ->lookup(NULL, [
    1,
  ])
    ->willReturn([]);
  $plugin = new MenuLinkParent([], 'map', [], $this->migrateLookup
    ->reveal(), $this->menuLinkManager
    ->reveal(), $this->menuLinkStorage
    ->reveal(), $this->migration
    ->reveal());
  $this
    ->expectException(MigrateSkipRowException::class);
  $this
    ->expectExceptionMessage("No parent link found for plid '{$parent_id}' in menu '{$menu_name}'.");
  $plugin
    ->transform($source_value, $this->migrateExecutable, $this->row, 'destination');
}