function MenuLinkParentTest::testLookupMigrations

Tests the lookup_migrations option.

@dataProvider providerLookupMigrations

Parameters

int $plid: The ID of the parent menu link.

array $configuration: The plugin configuration being tested.

string $expected_result: The expected value(s) of the migration process plugin.

File

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

Class

MenuLinkParentTest
Tests the menu link parent process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testLookupMigrations(int $plid, array $configuration, string $expected_result) : void {
    $source_value = [
        $plid,
        'some_menu',
        'https://www.example.com',
    ];
    $this->migration
        ->id()
        ->willReturn('this_migration');
    $this->migrateLookup
        ->lookup('this_migration', [
        1,
    ])
        ->willReturn([
        [
            'id' => 101,
        ],
    ]);
    $this->migrateLookup
        ->lookup('some_migration', [
        2,
    ])
        ->willReturn([
        [
            'id' => 202,
        ],
    ]);
    $this->migrateLookup
        ->lookup('some_migration', [
        3,
    ])
        ->willReturn([]);
    $this->migrateLookup
        ->lookup('another_migration', [
        3,
    ])
        ->willReturn([
        [
            'id' => 303,
        ],
    ]);
    $menu_link_content_this = $this->prophesize(MenuLinkContent::class);
    $menu_link_content_this->getPluginId()
        ->willReturn('menu_link_content:this_migration');
    $this->menuLinkStorage
        ->load(101)
        ->willReturn($menu_link_content_this);
    $menu_link_content_some = $this->prophesize(MenuLinkContent::class);
    $menu_link_content_some->getPluginId()
        ->willReturn('menu_link_content:some_migration');
    $this->menuLinkStorage
        ->load(202)
        ->willReturn($menu_link_content_some);
    $menu_link_content_another = $this->prophesize(MenuLinkContent::class);
    $menu_link_content_another->getPluginId()
        ->willReturn('menu_link_content:another_migration');
    $this->menuLinkStorage
        ->load(303)
        ->willReturn($menu_link_content_another);
    $plugin = new MenuLinkParent($configuration, 'menu_link', [], $this->migrateLookup
        ->reveal(), $this->menuLinkManager
        ->reveal(), $this->menuLinkStorage
        ->reveal(), $this->migration
        ->reveal());
    $result = $plugin->transform($source_value, $this->migrateExecutable, $this->row, 'destination');
    $this->assertSame($expected_result, $result);
}

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