function MigrateLanguageContentCommentSettingsNoEntityTranslationTest::testLanguageCommentSettings
Same name in other branches
- 8.9.x core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentCommentSettingsNoEntityTranslationTest.php \Drupal\Tests\language\Kernel\Migrate\d7\MigrateLanguageContentCommentSettingsNoEntityTranslationTest::testLanguageCommentSettings()
- 10 core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentCommentSettingsNoEntityTranslationTest.php \Drupal\Tests\language\Kernel\Migrate\d7\MigrateLanguageContentCommentSettingsNoEntityTranslationTest::testLanguageCommentSettings()
- 11.x core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentCommentSettingsNoEntityTranslationTest.php \Drupal\Tests\language\Kernel\Migrate\d7\MigrateLanguageContentCommentSettingsNoEntityTranslationTest::testLanguageCommentSettings()
Tests migration of content language settings.
File
-
core/
modules/ language/ tests/ src/ Kernel/ Migrate/ d7/ MigrateLanguageContentCommentSettingsNoEntityTranslationTest.php, line 60
Class
- MigrateLanguageContentCommentSettingsNoEntityTranslationTest
- Tests language content comment settings migration with no entity translation.
Namespace
Drupal\Tests\language\Kernel\Migrate\d7Code
public function testLanguageCommentSettings() {
// Confirm there is no message about a missing bundle.
$this->assertEmpty($this->migrateMessages, $this->migrateMessages['error'][0] ?? '');
// Article and Blog content type have multilingual settings of 'Enabled,
// with Translation'. Assert that comments are 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_blog');
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_blog', $config->getTargetBundle());
$this->assertSame('current_interface', $config->getDefaultLangcode());
$this->assertTrue($config->isLanguageAlterable());
$this->assertSame($third_party_settings, $config->get('third_party_settings'));
// Page content type has multilingual settings of 'Enabled'. Assert that
// comments are translatable and default language is 'current_interface'.
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_page');
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_page', $config->getTargetBundle());
$this->assertSame('current_interface', $config->getDefaultLangcode());
$this->assertTrue($config->isLanguageAlterable());
$this->assertSame($third_party_settings, $config->get('third_party_settings'));
// The content type with a long name has multilingual settings of 'Enabled'.
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_a_thirty_two_char');
$this->assertFalse($config->isNew());
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_a_thirty_two_char', $config->getTargetBundle());
$this->assertSame('current_interface', $config->getDefaultLangcode());
$this->assertTrue($config->isLanguageAlterable());
$this->assertSame($third_party_settings, $config->get('third_party_settings'));
// Test content type has multilingual settings of 'Enabled, with field
// translation'.
$config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_test_content_type');
$this->assertSame('comment', $config->getTargetEntityTypeId());
$this->assertSame('comment_node_test_content_type', $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'));
// Assert that non-translatable content is not translatable and the default
// language is 'site_default.
$not_translatable = [
'comment_node_book',
'comment_forum',
];
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}");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.