function SimplenewsI18nTest::setUpLanguages in Simplenews 8
Set up configuration for multiple languages.
1 call to SimplenewsI18nTest::setUpLanguages()
- SimplenewsI18nTest::setUp in src/
Tests/ SimplenewsI18nTest.php - Sets up a Drupal site for running functional and integration tests.
File
- src/
Tests/ SimplenewsI18nTest.php, line 56
Class
- SimplenewsI18nTest
- Translation of newsletters and issues.
Namespace
Drupal\simplenews\TestsCode
function setUpLanguages() {
// Add languages.
$this->defaultLanguage = 'en';
$this->secondaryLanguage = 'es';
$this
->addLanguage($this->secondaryLanguage);
// Display the language widget.
$config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'simplenews_issue');
$config
->setLanguageAlterable(TRUE);
$config
->save();
// Make Simplenews issue translatable.
\Drupal::service('content_translation.manager')
->setEnabled('node', 'simplenews_issue', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
\Drupal::service('router.builder')
->rebuild();
// Make Simplenews issue body translatable.
$field = FieldConfig::loadByName('node', 'simplenews_issue', 'body');
$field
->setTranslatable(TRUE);
$field
->save();
$this
->rebuildContainer();
}