Unverified Commit e72c88fc authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3110669 by quietone, ravi.shankar, Gábor Hojtsy, catch, xjm, daffie:...

Issue #3110669 by quietone, ravi.shankar, Gábor Hojtsy, catch, xjm, daffie: Migrate d7 menu language content settings
parent 402567d1
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
id: d7_language_content_menu_settings
label: Drupal 7 language content menu settings
migration_tags:
  - Drupal 7
  - Configuration
source:
  plugin: extension
  name: i18n_menu
  constants:
    target_type: menu_link_content
    langcode: site_default
    enabled: true
    hide: 0
process:
  target_entity_type_id: constants/target_type
  # menu_link_content has a bundle key but no bundle support so use the entity
  # type as the bundle.
  target_bundle: constants/target_type
  default_langcode: constants/langcode
  # Drupal 7 menus are translated when the i18n_menu module is enabled.
  language_alterable: status
  third_party_settings/content_translation/enabled: constants/enabled
  third_party_settings/content_translation/bundle_settings/untranslatable_fields_hide: constants/hide
destination:
  plugin: entity:language_content_settings
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ finished:
    taxonomy: language
  7:
    i18n_taxonomy: language
    i18n_menu:
      - language
    locale:
      - language
      - system
    system: language
+58 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\language\Kernel\Migrate\d7;

use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;

/**
 * Tests migration of i18n_menu settings.
 *
 * @group migrate_drupal_7
 */
class MigrateLanguageContentMenuSettingsTest extends MigrateDrupal7TestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'content_translation',
    'language',
    'link',
    'menu_link_content',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->installEntitySchema('menu_link_content');
    $this->executeMigrations([
      'language',
      'd7_menu',
      'd7_language_content_menu_settings',
    ]);
  }

  /**
   * Tests migration of menu translation ability.
   */
  public function testLanguageContentMenu() {
    $config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
    $this->assertInstanceOf(ContentLanguageSettings::class, $config);
    $this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
    $this->assertSame('menu_link_content', $config->getTargetBundle());
    $this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
    $this->assertSame(TRUE, $config->isLanguageAlterable());
    $settings = [
      'enabled' => TRUE,
      'bundle_settings' => [
        'untranslatable_fields_hide' => '0',
      ],
    ];
    $this->assertSame($settings, $config->getThirdPartySettings('content_translation'));
  }

}
+829 −7

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ protected function getEntityCounts() {
      'file' => 3,
      'filter_format' => 7,
      'image_style' => 7,
      'language_content_settings' => 20,
      'language_content_settings' => 21,
      'node' => 7,
      'node_type' => 7,
      'rdf_mapping' => 8,
@@ -200,6 +200,7 @@ protected function getMissingPaths() {
      'Field translation',
      'Internationalization',
      'Locale',
      'Menu translation',
      'String translation',
      'Taxonomy translation',
      'Translation sets',