function ModerationLocaleTest::submitNodeForm
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::submitNodeForm()
- 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::submitNodeForm()
- 10 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 563
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 = str_contains($this->getSession()
->getCurrentUrl(), '/node/add/');
$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 ? 'Save' : 'Save (this translation)';
$this->submitForm($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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.