View source
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d6;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
class MigrateLanguageContentCommentSettingsTest extends MigrateDrupal6TestBase {
protected static $modules = [
'comment',
'language',
'content_translation',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'comment',
]);
$this
->executeMigrations([
'language',
'd6_comment_type',
'd6_language_content_comment_settings',
]);
}
public function testLanguageCommentSettings() {
$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'));
$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'));
$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}");
}
}
}