View source
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d7;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal7TestBase {
protected static $modules = [
'language',
'content_translation',
'taxonomy',
'text',
];
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('taxonomy_term');
$this
->executeMigrations([
'language',
'd7_taxonomy_vocabulary',
'd7_language_content_taxonomy_vocabulary_settings',
]);
}
public function testLanguageContentTaxonomy() {
$target_entity = 'taxonomy_term';
$this
->assertLanguageContentSettings($target_entity, 'tags', LanguageInterface::LANGCODE_NOT_SPECIFIED, FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'forums', LanguageInterface::LANGCODE_NOT_SPECIFIED, FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocabulary_name_much_longer_th', LanguageInterface::LANGCODE_NOT_SPECIFIED, FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'test_vocabulary', LanguageInterface::LANGCODE_NOT_SPECIFIED, FALSE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocablocalized', LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE, [
'enabled' => TRUE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocabtranslate', LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE, [
'enabled' => FALSE,
]);
$this
->assertLanguageContentSettings($target_entity, 'vocabfixed', 'fr', 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'));
}
}