protected function ModerationStateTestBase::enableModerationThroughUI in Workbench Moderation 8.2
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 ModerationStateTestBase::enableModerationThroughUI()
- ModerationStateNodeTypeTest::testEnablingOnExistingContent in src/
Tests/ ModerationStateNodeTypeTest.php - A node type without moderation state enabled.
- ModerationStateTestBase::createContentTypeFromUI in src/
Tests/ ModerationStateTestBase.php - Creates a content-type from the UI.
File
- src/
Tests/ ModerationStateTestBase.php, line 111
Class
- ModerationStateTestBase
- Defines a base class for moderation state tests.
Namespace
Drupal\workbench_moderation\TestsCode
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 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'));
}