View source
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d6;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal6TestBase {
protected static $modules = [
'language',
'content_translation',
'taxonomy',
];
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('taxonomy_term');
$this
->executeMigrations([
'language',
'd6_taxonomy_vocabulary',
'd6_language_content_taxonomy_vocabulary_settings',
]);
}
public function testLanguageContentTaxonomy() {
$target_entity = 'taxonomy_term';
$this
->assertLanguageContentSettings($target_entity, 'vocabulary_1_i_0_', LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocabulary_2_i_1_', 'fr', FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocabulary_3_i_2_', LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocabulary_name_much_longer_th', LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE, [
'enabled' => TRUE,
]);
$this
->assertLanguageContentSettings($target_entity, 'tags', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'forums', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'type', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, [
'enabled' => FALSE,
]);
}
public function assertLanguageContentSettings($target_entity, $bundle, $default_langcode, $language_alterable, array $third_party_settings) {
$config = ContentLanguageSettings::load($target_entity . "." . $bundle);
$this
->assertInstanceOf(ContentLanguageSettings::class, $config);
$this
->assertSame($target_entity, $config
->getTargetEntityTypeId());
$this
->assertSame($bundle, $config
->getTargetBundle());
$this
->assertSame($default_langcode, $config
->getDefaultLangcode());
$this
->assertSame($language_alterable, $config
->isLanguageAlterable());
$this
->assertSame($third_party_settings, $config
->getThirdPartySettings('content_translation'));
}
}