You are here

protected function LingotekNodeWorkbenchModerationTranslationTest::enableModerationThroughUI in Lingotek Translation 3.7.x

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

Enable moderation for a specified content type, using the UI.

Parameters

string $content_type_id: Machine name.

string[] $allowed_states: Array of allowed state IDs.

string $default_state: Default state.

1 call to LingotekNodeWorkbenchModerationTranslationTest::enableModerationThroughUI()
LingotekNodeWorkbenchModerationTranslationTest::setUp in tests/src/Functional/LingotekNodeWorkbenchModerationTranslationTest.php

File

tests/src/Functional/LingotekNodeWorkbenchModerationTranslationTest.php, line 183

Class

LingotekNodeWorkbenchModerationTranslationTest
Tests translating a node with workbench moderation enabled.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function enableModerationThroughUI($content_type_id, array $allowed_states, $default_state) {
  $this
    ->drupalGet('admin/structure/types/manage/' . $content_type_id . '/moderation');
  $this
    ->assertFieldByName('enable_moderation_state');
  $this
    ->assertNoFieldChecked('edit-enable-moderation-state');
  $edit['enable_moderation_state'] = 1;

  /** @var \Drupal\workbench_moderation\Entity\ModerationState $state */
  foreach (ModerationState::loadMultiple() as $id => $state) {
    $key = $state
      ->isPublishedState() ? 'allowed_moderation_states_published[' . $state
      ->id() . ']' : 'allowed_moderation_states_unpublished[' . $state
      ->id() . ']';
    $edit[$key] = (int) in_array($id, $allowed_states);
  }
  $edit['default_moderation_state'] = $default_state;
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
}