You are here

public function MigrateMenuLinkTranslationTest::testMenuLinks in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTranslationTest.php \Drupal\Tests\menu_link_content\Kernel\Migrate\d6\MigrateMenuLinkTranslationTest::testMenuLinks()
  2. 9 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 47

Class

MigrateMenuLinkTranslationTest
Menu link migration.

Namespace

Drupal\Tests\menu_link_content\Kernel\Migrate\d6

Code

public function testMenuLinks() {

  /** @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());
}