You are here

protected function ChineseBulkTranslationTest::setUp in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  2. 4.0.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  3. 3.0.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  4. 3.1.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  5. 3.2.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  6. 3.3.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  7. 3.5.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  8. 3.6.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  9. 3.7.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()
  10. 3.8.x tests/src/Functional/ChineseBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\ChineseBulkTranslationTest::setUp()

Overrides LingotekTestBase::setUp

File

tests/src/Functional/ChineseBulkTranslationTest.php, line 22

Class

ChineseBulkTranslationTest
Tests translating into chinese locales.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Create Article node types.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add locale.
  // TODO: Use the dashboard for adding the language
  //    $post = [
  //      'code' => 'zh_CN',
  //      'language' => 'Chinese',
  //      'native' => 'Chinese',
  //      'direction' => '',
  //    ];
  //    $this->drupalPost('/admin/lingotek/dashboard_endpoint', 'application/json', $post);
  ConfigurableLanguage::createFromLangcode('zh-hans')
    ->setThirdPartySetting('lingotek', 'locale', 'zh_CN')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);
  drupal_static_reset();
  \Drupal::entityTypeManager()
    ->clearCachedDefinitions();
  $this
    ->applyEntityUpdates();

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $this
    ->saveLingotekContentTranslationSettingsForNodeTypes([
    'article',
  ], 'manual');
  $this
    ->saveLingotekConfigTranslationSettings([
    'node_type' => 'manual',
  ]);
}