You are here

protected function LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  2. 4.0.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  3. 3.1.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  4. 3.2.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  5. 3.3.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  6. 3.4.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  7. 3.5.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  8. 3.7.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
  9. 3.8.x tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php \Drupal\Tests\lingotek\Functional\LingotekWorkbenchModerationSettingsTest::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 LingotekWorkbenchModerationSettingsTest::enableModerationThroughUI()
LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings in tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php
Tests that the workbench moderation settings are stored correctly.

File

tests/src/Functional/LingotekWorkbenchModerationSettingsTest.php, line 169

Class

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