You are here

protected function LingotekNodeBulkDisabledTargetOverrideTranslationTest::setUp in Lingotek Translation 3.7.x

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::setUp()
  2. 3.5.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::setUp()
  3. 3.6.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::setUp()
  4. 3.8.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::setUp()

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php, line 32

Class

LingotekNodeBulkDisabledTargetOverrideTranslationTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

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

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX')
    ->save();
  ConfigurableLanguage::createFromLangcode('ca')
    ->setThirdPartySetting('lingotek', 'locale', 'ca_ES')
    ->save();
  $profile = LingotekProfile::create([
    'label' => 'Profile with disabled targets',
    'id' => 'profile_with_disabled_targets',
    'project' => 'test_project',
    'vault' => 'test_vault',
    'auto_upload' => FALSE,
    'workflow' => 'test_workflow',
    'language_overrides' => [
      'es' => [
        'overrides' => 'custom',
        'custom' => [
          'auto_request' => TRUE,
          'workflow' => 'test_workflow',
          'vault' => 'test_vault',
        ],
      ],
      'ca' => [
        'overrides' => 'disabled',
      ],
    ],
  ]);
  $profile
    ->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',
  ], 'profile_with_disabled_targets');
}