136e5331ecac633dece7830ef568b0253942d3bf
[yaffs-website] / web / core / modules / content_translation / tests / src / Kernel / Migrate / d7 / MigrateEntityTranslationSettingsTest.php
1 <?php
2
3 namespace Drupal\Tests\content_translation\Kernel\Migrate\d7;
4
5 use Drupal\Core\Language\LanguageInterface;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests the migration of entity translation settings.
10  *
11  * @group migrate_drupal_7
12  */
13 class MigrateEntityTranslationSettingsTest extends MigrateDrupal7TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = [
19     'comment',
20     'content_translation',
21     'language',
22     'menu_ui',
23     // Required for translation migrations.
24     'migrate_drupal_multilingual',
25     'node',
26     'taxonomy',
27     'text',
28     'user',
29   ];
30
31   /**
32    * {@inheritdoc}
33    */
34   protected function setUp() {
35     parent::setUp();
36
37     $this->installConfig([
38       'comment',
39       'content_translation',
40       'node',
41       'taxonomy',
42       'user',
43     ]);
44
45     $this->installEntitySchema('comment');
46     $this->installEntitySchema('node');
47     $this->installEntitySchema('taxonomy_term');
48     $this->installEntitySchema('user');
49
50     $this->executeMigrations([
51       'd7_comment_type',
52       'd7_node_type',
53       'd7_taxonomy_vocabulary',
54       'd7_entity_translation_settings',
55     ]);
56   }
57
58   /**
59    * Tests entity translation settings migration.
60    */
61   public function testEntityTranslationSettingsMigration() {
62     // Tests 'comment_node_test_content_type' entity translation settings.
63     $config = $this->config('language.content_settings.comment.comment_node_test_content_type');
64     $this->assertSame($config->get('target_entity_type_id'), 'comment');
65     $this->assertSame($config->get('target_bundle'), 'comment_node_test_content_type');
66     $this->assertSame($config->get('default_langcode'), 'current_interface');
67     $this->assertFalse((bool) $config->get('language_alterable'));
68     $this->assertTrue((bool) $config->get('third_party_settings.content_translation.enabled'));
69     $this->assertFalse((bool) $config->get('third_party_settings.content_translation.bundle_settings.untranslatable_fields_hide'));
70
71     // Tests 'test_content_type' entity translation settings.
72     $config = $this->config('language.content_settings.node.test_content_type');
73     $this->assertSame($config->get('target_entity_type_id'), 'node');
74     $this->assertSame($config->get('target_bundle'), 'test_content_type');
75     $this->assertSame($config->get('default_langcode'), LanguageInterface::LANGCODE_NOT_SPECIFIED);
76     $this->assertTrue((bool) $config->get('language_alterable'));
77     $this->assertTrue((bool) $config->get('third_party_settings.content_translation.enabled'));
78     $this->assertFalse((bool) $config->get('third_party_settings.content_translation.bundle_settings.untranslatable_fields_hide'));
79
80     // Tests 'test_vocabulary' entity translation settings.
81     $config = $this->config('language.content_settings.taxonomy_term.test_vocabulary');
82     $this->assertSame($config->get('target_entity_type_id'), 'taxonomy_term');
83     $this->assertSame($config->get('target_bundle'), 'test_vocabulary');
84     $this->assertSame($config->get('default_langcode'), LanguageInterface::LANGCODE_SITE_DEFAULT);
85     $this->assertFalse((bool) $config->get('language_alterable'));
86     $this->assertTrue((bool) $config->get('third_party_settings.content_translation.enabled'));
87     $this->assertFalse((bool) $config->get('third_party_settings.content_translation.bundle_settings.untranslatable_fields_hide'));
88
89     // Tests 'user' entity translation settings.
90     $config = $this->config('language.content_settings.user.user');
91     $this->assertSame($config->get('target_entity_type_id'), 'user');
92     $this->assertSame($config->get('target_bundle'), 'user');
93     $this->assertSame($config->get('default_langcode'), LanguageInterface::LANGCODE_SITE_DEFAULT);
94     $this->assertFalse((bool) $config->get('language_alterable'));
95     $this->assertTrue((bool) $config->get('third_party_settings.content_translation.enabled'));
96     $this->assertFalse((bool) $config->get('third_party_settings.content_translation.bundle_settings.untranslatable_fields_hide'));
97   }
98
99 }