Commit 53810d22 authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2981393 by quietone, masipila, heddn, Gábor Hojtsy, maxocub: Migrate D6...

Issue #2981393 by quietone, masipila, heddn, Gábor Hojtsy, maxocub: Migrate D6 comment type language settings
parent a98b5876
id: d6_language_content_comment_settings
label: Drupal 6 language content comment settings
migration_tags:
- Drupal 6
- Configuration
- Multilingual
source:
plugin: d6_language_content_settings
constants:
target_type: comment
id_prefix: comment_node_
label_suffix: comment
process:
# Ignore i18n_node_options_[node_type] options not available in Drupal 8,
# i18n_required_node and i18n_newnode_current
target_bundle:
-
plugin: concat
source:
- constants/id_prefix
- type
-
plugin: static_map
bypass: true
# The Forum module provides its own comment type (comment_forum), which we
# want to reuse if it exists.
map:
comment_node_forum: comment_forum
target_entity_type_id: constants/target_type
default_langcode:
-
plugin: static_map
source: language_content_type
map:
0: site_default
1: current_interface
2: current_interface
-
plugin: skip_on_empty
method: row
language_alterable:
plugin: static_map
source: language_content_type
map:
0: false
1: true
2: true
'third_party_settings/content_translation/enabled':
plugin: static_map
source: language_content_type
map:
# In the case of being 0, it will be skipped. We are not actually setting
# a null value.
0: NULL
1: false
2: false
destination:
plugin: entity:language_content_settings
content_translation_update_definitions:
- comment
migration_dependencies:
required:
- d6_comment_type
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d6;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Tests migration of language content comment settings.
*
* @group migrate_drupal_6
*/
class MigrateLanguageContentCommentSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'comment',
'language',
'content_translation',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['comment']);
$this->executeMigrations([
'd6_comment_type',
'd6_language_content_comment_settings',
]);
}
/**
* Tests migration of comment content language settings.
*/
public function testLanguageCommentSettings() {
// Article and Employee content type have multilingual settings of 'Enabled,
// with Translation'. Assert that comments are not translatable and the
// default language is 'current_interface'.
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_article');
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_article', $config->getTargetBundle());
$this->assertSame('current_interface', $config->getDefaultLangcode());
$this->assertTrue($config->isLanguageAlterable());
$third_party_settings = [
'content_translation' => [
'enabled' => FALSE,
],
];
$this->assertSame($third_party_settings, $config->get('third_party_settings'));
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_employee');
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_employee', $config->getTargetBundle());
$this->assertSame('current_interface', $config->getDefaultLangcode());
$this->assertTrue($config->isLanguageAlterable());
$this->assertSame($third_party_settings, $config->get('third_party_settings'));
// Sponsor content type has multilingual settings of 'Enabled'. Assert that
// comments are not translatable and the default language is
// 'current_interface'.
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_sponsor');
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_sponsor', $config->getTargetBundle());
$this->assertSame('current_interface', $config->getDefaultLangcode());
$this->assertTrue($config->isLanguageAlterable());
$this->assertSame($third_party_settings, $config->get('third_party_settings'));
// Assert that non-translatable content is not translatable and the default
// language is 'site_default.
$not_translatable = [
'comment_node_company',
'comment_node_event',
'comment_node_page',
'comment_node_story',
'comment_node_test_event',
'comment_node_test_page',
'comment_node_test_planet',
'comment_node_test_story',
'comment_forum',
'comment_node_event',
];
foreach ($not_translatable as $bundle) {
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', $bundle);
$this->assertTrue($config->isDefaultConfiguration());
$this->assertFalse($config->isLanguageAlterable());
$this->assertSame('site_default', $config->getDefaultLangcode(), "Default language is not 'site_default' for comment bundle $bundle");
}
}
}
...@@ -68,12 +68,12 @@ protected function getEntityCounts() { ...@@ -68,12 +68,12 @@ protected function getEntityCounts() {
'contact_message' => 0, 'contact_message' => 0,
'configurable_language' => 5, 'configurable_language' => 5,
'editor' => 2, 'editor' => 2,
'field_config' => 92, 'field_config' => 93,
'field_storage_config' => 66, 'field_storage_config' => 66,
'file' => 7, 'file' => 7,
'filter_format' => 7, 'filter_format' => 7,
'image_style' => 5, 'image_style' => 5,
'language_content_settings' => 10, 'language_content_settings' => 14,
'node' => 18, 'node' => 18,
// The 'book' module provides the 'book' node type, and the migration // The 'book' module provides the 'book' node type, and the migration
// creates 12 node types. // creates 12 node types.
...@@ -94,7 +94,7 @@ protected function getEntityCounts() { ...@@ -94,7 +94,7 @@ protected function getEntityCounts() {
'date_format' => 11, 'date_format' => 11,
'entity_form_display' => 29, 'entity_form_display' => 29,
'entity_form_mode' => 1, 'entity_form_mode' => 1,
'entity_view_display' => 57, 'entity_view_display' => 58,
'entity_view_mode' => 14, 'entity_view_mode' => 14,
'base_field_override' => 38, 'base_field_override' => 38,
]; ];
...@@ -107,7 +107,7 @@ protected function getEntityCountsIncremental() { ...@@ -107,7 +107,7 @@ protected function getEntityCountsIncremental() {
$counts = $this->getEntityCounts(); $counts = $this->getEntityCounts();
$counts['block_content'] = 3; $counts['block_content'] = 3;
$counts['comment'] = 9; $counts['comment'] = 9;
$counts['entity_view_display'] = 57; $counts['entity_view_display'] = 58;
$counts['entity_view_mode'] = 14; $counts['entity_view_mode'] = 14;
$counts['file'] = 8; $counts['file'] = 8;
$counts['menu_link_content'] = 11; $counts['menu_link_content'] = 11;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment