You are here

protected function LingotekWorkbenchModerationTest::enableModerationThroughUI in Lingotek Translation 3.5.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  2. 4.0.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  3. 3.1.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  4. 3.2.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  5. 3.3.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  6. 3.4.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  7. 3.6.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  8. 3.7.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::enableModerationThroughUI()
  9. 3.8.x tests/src/Functional/LingotekWorkbenchModerationTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationTest::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.

2 calls to LingotekWorkbenchModerationTest::enableModerationThroughUI()
LingotekWorkbenchModerationTest::setUp in tests/src/Functional/LingotekWorkbenchModerationTest.php
LingotekWorkbenchModerationTest::testDownloadWhenContentModerationWasSetupAfterLingotek in tests/src/Functional/LingotekWorkbenchModerationTest.php

File

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

Class

LingotekWorkbenchModerationTest
Tests setting up the integration with workbench moderation.

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'));
}