MigrateLanguageContentSettingsTest.php in Drupal 9        
                          
                  
                        
  
  
  
  
File
  core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentSettingsTest.php
  
    View source  
  <?php
namespace Drupal\Tests\language\Kernel\Migrate\d7;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
  
  protected static $modules = [
    'node',
    'text',
    'language',
    'content_translation',
    'menu_ui',
  ];
  
  protected function setUp() : void {
    parent::setUp();
    $this
      ->migrateContentTypes();
    $this
      ->executeMigrations([
      'language',
      'd7_language_content_settings',
    ]);
  }
  
  public function testLanguageContent() {
    
    $config = $this
      ->config('language.content_settings.node.blog');
    $this
      ->assertSame($config
      ->get('target_entity_type_id'), 'node');
    $this
      ->assertSame($config
      ->get('target_bundle'), 'blog');
    $this
      ->assertSame($config
      ->get('default_langcode'), 'current_interface');
    $this
      ->assertFalse($config
      ->get('language_alterable'));
    $this
      ->assertTrue($config
      ->get('third_party_settings.content_translation.enabled'));
    
    $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'page');
    $this
      ->assertFalse($config
      ->isDefaultConfiguration());
    $this
      ->assertTrue($config
      ->isLanguageAlterable());
    $this
      ->assertSame($config
      ->getDefaultLangcode(), 'current_interface');
    
    $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'forum');
    $this
      ->assertTrue($config
      ->isDefaultConfiguration());
    $this
      ->assertFalse($config
      ->isLanguageAlterable());
    $this
      ->assertSame($config
      ->getDefaultLangcode(), 'site_default');
    
    $messages = $this->migration
      ->getIdMap()
      ->getMessages()
      ->fetchAll();
    $this
      ->assertEmpty($messages);
    
    $config = $this
      ->config('language.content_settings.node.test_content_type');
    $this
      ->assertTrue($config
      ->get('third_party_settings.content_translation.enabled'));
    $this
      ->assertSame($config
      ->get('default_langcode'), 'und');
    
    $config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'book');
    $this
      ->assertTrue($config
      ->isDefaultConfiguration());
    $this
      ->assertFalse($config
      ->isLanguageAlterable());
    $this
      ->assertSame($config
      ->getDefaultLangcode(), 'site_default');
  }
}