You are here

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

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

Overrides LingotekTestBase::setUp

File

tests/src/Functional/LingotekWorkbenchModerationTest.php, line 25

Class

LingotekWorkbenchModerationTest
Tests setting up the integration with workbench moderation.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

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

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX')
    ->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);
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'page')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'page', TRUE);
  $this
    ->applyEntityUpdates();

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();

  // Enable workbench moderation.
  $this
    ->enableModerationThroughUI('article', [
    'draft',
    'needs_review',
    'published',
  ], 'draft');
  $this
    ->saveLingotekContentTranslationSettings([
    'node' => [
      'article' => [
        'profiles' => 'automatic',
        'fields' => [
          'title' => 1,
          'body' => 1,
        ],
        'moderation' => [
          'upload_status' => 'draft',
          'download_transition' => 'draft_needs_review',
        ],
      ],
      'page' => [
        'profiles' => 'automatic',
        'fields' => [
          'title' => 1,
          'body' => 1,
        ],
      ],
    ],
  ]);
}