You are here

public function MigrateMenuTranslationTest::testMenuTranslation in Drupal 9

Tests migration of menu translations.

File

core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTranslationTest.php, line 43

Class

MigrateMenuTranslationTest
Tests menu translation migration.

Namespace

Drupal\Tests\system\Kernel\Migrate\d7

Code

public function testMenuTranslation() {
  $language_manager = \Drupal::service('language_manager');
  $config_translation = $language_manager
    ->getLanguageConfigOverride('is', 'system.menu.main');
  $this
    ->assertSame('is - Main menu', $config_translation
    ->get('label'));
  $this
    ->assertSame('is - Main menu description', $config_translation
    ->get('description'));
  $config_translation = $language_manager
    ->getLanguageConfigOverride('fr', 'system.menu.main');
  $this
    ->assertSame('fr - Main menu', $config_translation
    ->get('label'));
  $this
    ->assertSame('fr - Main menu description', $config_translation
    ->get('description'));

  // Translate and localize menu.
  $config_translation = $language_manager
    ->getLanguageConfigOverride('fr', 'system.menu.menu-test-menu');
  $this
    ->assertSame('fr - Test menu description', $config_translation
    ->get('description'));

  // No translations for fixed language menu.
  $config_translation = $language_manager
    ->getLanguageConfigOverride('fr', 'menu-fixedlang');
  $this
    ->assertNull($config_translation
    ->get('description'));
  $this
    ->assertNull($config_translation
    ->get('label'));
  $config_translation = $language_manager
    ->getLanguageConfigOverride('is', 'menu-fixedlang');
  $this
    ->assertNull($config_translation
    ->get('description'));
  $this
    ->assertNull($config_translation
    ->get('label'));
}