function ModerationContentTranslationTest::testModerationWithExistingContent
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Functional/ModerationContentTranslationTest.php \Drupal\Tests\content_moderation\Functional\ModerationContentTranslationTest::testModerationWithExistingContent()
- 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationContentTranslationTest.php \Drupal\Tests\content_moderation\Functional\ModerationContentTranslationTest::testModerationWithExistingContent()
- 10 core/modules/content_moderation/tests/src/Functional/ModerationContentTranslationTest.php \Drupal\Tests\content_moderation\Functional\ModerationContentTranslationTest::testModerationWithExistingContent()
Tests existing translations being edited after enabling content moderation.
File
-
core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationContentTranslationTest.php, line 69
Class
- ModerationContentTranslationTest
- Test content_moderation functionality with content_translation.
Namespace
Drupal\Tests\content_moderation\FunctionalCode
public function testModerationWithExistingContent() : void {
// Create a published article in English.
$edit = [
'title[0][value]' => 'Published English node',
'langcode[0][value]' => 'en',
];
$this->drupalGet('node/add/article');
$this->submitForm($edit, 'Save');
$this->assertSession()
->pageTextContains('Article Published English node has been created.');
$english_node = $this->drupalGetNodeByTitle('Published English node');
// Add a French translation.
$this->drupalGet('node/' . $english_node->id() . '/translations');
$this->clickLink('Add');
$edit = [
'title[0][value]' => 'Published French node',
];
$this->submitForm($edit, 'Save (this translation)');
$this->assertSession()
->pageTextContains('Article Published French node has been updated.');
// Install content moderation and enable moderation on Article node type.
\Drupal::service('module_installer')->install([
'content_moderation',
]);
$workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()
->addEntityTypeAndBundle('node', 'article');
$workflow->save();
$this->drupalLogin($this->rootUser);
// Edit the English node.
$this->drupalGet('node/' . $english_node->id() . '/edit');
$this->assertSession()
->statusCodeEquals(200);
$edit = [
'title[0][value]' => 'Published English new node',
];
$this->submitForm($edit, 'Save');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('Article Published English new node has been updated.');
// Edit the French translation.
$this->drupalGet('fr/node/' . $english_node->id() . '/edit');
$this->assertSession()
->statusCodeEquals(200);
$edit = [
'title[0][value]' => 'Published French new node',
];
$this->submitForm($edit, 'Save (this translation)');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('Article Published French new node has been updated.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.