protected function ModerationLocaleTest::submitNodeForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::submitNodeForm()
Submits the node form at the current URL with the specified values.
Parameters
string $title: The node title.
string $moderation_state: The moderation state.
bool $default_translation: (optional) Whether we are editing the default translation.
string|null $langcode: (optional) The node language. Defaults to English.
Return value
\Drupal\node\NodeInterface|null A node object if a new one is being created, NULL otherwise.
2 calls to ModerationLocaleTest::submitNodeForm()
- ModerationLocaleTest::testLanguageIndependentContentModeration in core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationLocaleTest.php - Tests that individual translations can be moderated independently.
- ModerationLocaleTest::testNewTranslationSourceValues in core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationLocaleTest.php - Checks that new translation values are populated properly.
File
- core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationLocaleTest.php, line 459
Class
- ModerationLocaleTest
- Test content_moderation functionality with localization and translation.
Namespace
Drupal\Tests\content_moderation\FunctionalCode
protected function submitNodeForm($title, $moderation_state, $default_translation = FALSE, $langcode = 'en') {
$is_new = strpos($this
->getSession()
->getCurrentUrl(), '/node/add/') !== FALSE;
$edit = [
'title[0][value]' => $title,
'moderation_state[0][state]' => $moderation_state,
];
if ($is_new) {
$default_translation = TRUE;
$edit['langcode[0][value]'] = $langcode;
}
$submit = $default_translation ? t('Save') : t('Save (this translation)');
$this
->drupalPostForm(NULL, $edit, $submit);
$message = $is_new ? "Article {$title} has been created." : "Article {$title} has been updated.";
$this
->assertSession()
->pageTextContains($message);
return $is_new ? $this
->drupalGetNodeByTitle($title) : NULL;
}