You are here

protected function LingotekNodeCohesionRepeaterTranslationTest::setUp in Lingotek Translation 3.6.x

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekNodeCohesionRepeaterTranslationTest.php, line 53

Class

LingotekNodeCohesionRepeaterTranslationTest
Tests translating a node with multiple locales including paragraphs.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Place the actions and title block.
  $this
    ->drupalPlaceBlock('page_title_block', [
    'region' => 'content',
    'weight' => -5,
  ]);
  $this
    ->drupalPlaceBlock('local_tasks_block', [
    'region' => 'content',
    'weight' => -10,
  ]);

  // Add locales.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_ES')
    ->save();
  ConfigurableLanguage::createFromLangcode('es-ar')
    ->setThirdPartySetting('lingotek', 'locale', 'es_AR')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
    ->setLanguageAlterable(TRUE)
    ->save();
  ContentLanguageSettings::loadByEntityTypeBundle('cohesion_layout', 'cohesion_layout')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);
  \Drupal::service('content_translation.manager')
    ->setEnabled('cohesion_layout', 'cohesion_layout', TRUE);
  $this
    ->createCohesionField('node', 'article');
  $this
    ->createCohesionComponent();
  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();

  // Enable content moderation for articles.
  $workflow = $this
    ->createEditorialWorkflow();
  $this
    ->configureContentModeration('editorial', [
    'node' => [
      'article',
    ],
  ]);
  $this
    ->saveLingotekContentTranslationSettings([
    'node' => [
      'article' => [
        'profiles' => 'automatic',
        'fields' => [
          'title' => 1,
          'layout_canvas' => 1,
        ],
        'moderation' => [
          'upload_status' => 'published',
          'download_transition' => 'publish',
        ],
      ],
    ],
    'cohesion_layout' => [
      'cohesion_layout' => [
        'fields' => [
          'json_values' => 1,
        ],
      ],
    ],
  ]);

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'node+cohesion-with-repeater');
}