function MigrateMenuLinkTranslationTest::testMenuLinks

Same name in other branches
  1. 9 core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTranslationTest.php \Drupal\Tests\menu_link_content\Kernel\Migrate\d6\MigrateMenuLinkTranslationTest::testMenuLinks()
  2. 8.9.x core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTranslationTest.php \Drupal\Tests\menu_link_content\Kernel\Migrate\d6\MigrateMenuLinkTranslationTest::testMenuLinks()
  3. 10 core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTranslationTest.php \Drupal\Tests\menu_link_content\Kernel\Migrate\d6\MigrateMenuLinkTranslationTest::testMenuLinks()

Tests migration of menu links.

File

core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTranslationTest.php, line 49

Class

MigrateMenuLinkTranslationTest
Menu link migration.

Namespace

Drupal\Tests\menu_link_content\Kernel\Migrate\d6

Code

public function testMenuLinks() : void {
    
    /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
    $menu_link = MenuLinkContent::load(139)->getTranslation('fr');
    $this->assertInstanceOf(MenuLinkContent::class, $menu_link);
    $this->assertSame('fr - Test 2', $menu_link->getTitle());
    $this->assertSame('fr - Test menu link 2', $menu_link->getDescription());
    $this->assertSame('secondary-links', $menu_link->getMenuName());
    $this->assertTrue($menu_link->isEnabled());
    $this->assertTrue($menu_link->isExpanded());
    $this->assertSame([
        'query' => [
            'foo' => 'bar',
        ],
        'attributes' => [
            'title' => 'Test menu link 2',
        ],
    ], $menu_link->link->options);
    $this->assertSame('internal:/admin', $menu_link->link->uri);
    $this->assertSame(-49, $menu_link->getWeight());
    $menu_link = MenuLinkContent::load(139)->getTranslation('zu');
    $this->assertInstanceOf(MenuLinkContent::class, $menu_link);
    $this->assertSame('Test 2', $menu_link->getTitle());
    $this->assertSame('zu - Test menu link 2', $menu_link->getDescription());
    $this->assertSame('secondary-links', $menu_link->getMenuName());
    $this->assertTrue($menu_link->isEnabled());
    $this->assertTrue($menu_link->isExpanded());
    $this->assertSame([
        'query' => [
            'foo' => 'bar',
        ],
        'attributes' => [
            'title' => 'Test menu link 2',
        ],
    ], $menu_link->link->options);
    $this->assertSame('internal:/admin', $menu_link->link->uri);
    $this->assertSame(-49, $menu_link->getWeight());
    $menu_link = MenuLinkContent::load(140)->getTranslation('fr');
    $this->assertInstanceOf(MenuLinkContent::class, $menu_link);
    $this->assertSame('fr - Drupal.org', $menu_link->getTitle());
    $this->assertSame('', $menu_link->getDescription());
    $this->assertSame('secondary-links', $menu_link->getMenuName());
    $this->assertTrue($menu_link->isEnabled());
    $this->assertFalse($menu_link->isExpanded());
    $this->assertSame([
        'attributes' => [
            'title' => '',
        ],
    ], $menu_link->link->options);
    $this->assertSame('https://www.drupal.org', $menu_link->link->uri);
    $this->assertSame(-50, $menu_link->getWeight());
}

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