You are here

public function MenuLinkParentTest::testTransformExternal in Drupal 8

Tests the plugin when the parent is an external link.

@covers ::transform

File

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

Class

MenuLinkParentTest
Tests the menu link parent process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformExternal() {
  $menu_link_content = $this
    ->prophesize(MenuLinkContentInterface::class);
  $menu_link_content
    ->getPluginId()
    ->willReturn('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27');
  $this->menuLinkStorage
    ->loadByProperties([
    'link__uri' => 'http://example.com',
  ])
    ->willReturn([
    9054 => $menu_link_content,
  ]);
  $plugin = $this
    ->prophesize(PluginInspectionInterface::class);
  $this->menuLinkManager
    ->createInstance('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27')
    ->willReturn($plugin
    ->reveal());
  $plugin = new MenuLinkParent([], 'map', [], $this->migrateLookup
    ->reveal(), $this->menuLinkManager
    ->reveal(), $this->menuLinkStorage
    ->reveal(), $this->migration
    ->reveal());
  $result = $plugin
    ->transform([
    1,
    'admin',
    'http://example.com',
  ], $this->migrateExecutable, $this->row, 'destination_property');
  $this
    ->assertEquals('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27', $result);
}