function MenuLinkParentTest::testTransformException

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php \Drupal\Tests\migrate\Unit\process\MenuLinkParentTest::testTransformException()
  2. 8.9.x core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php \Drupal\Tests\migrate\Unit\process\MenuLinkParentTest::testTransformException()
  3. 11.x 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 94

Class

MenuLinkParentTest
Tests the menu link parent process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformException(array $source_value) : void {
    [
        $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');
}

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