function EntityStateChangeValidationTest::testExistingMultilingualContentWithNoModeration
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testExistingMultilingualContentWithNoModeration()
- 10 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testExistingMultilingualContentWithNoModeration()
- 11.x core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testExistingMultilingualContentWithNoModeration()
Tests that content without prior moderation information can be translated.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ EntityStateChangeValidationTest.php, line 285
Class
- EntityStateChangeValidationTest
- @coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator @group content_moderation
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testExistingMultilingualContentWithNoModeration() {
$this->setCurrentUser($this->adminUser);
// Enable French.
ConfigurableLanguage::createFromLangcode('fr')->save();
$node_type = NodeType::create([
'type' => 'example',
]);
$node_type->save();
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create([
'type' => 'example',
'title' => 'Test title',
'langcode' => 'en',
]);
$node->save();
$nid = $node->id();
$node = Node::load($nid);
// Creating a translation shouldn't break, even though there's no previous
// moderated revision for the new language.
$node_fr = $node->addTranslation('fr');
$node_fr->setTitle('Francais');
$node_fr->save();
// Enable moderation for our node type.
$workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()
->addEntityTypeAndBundle('node', 'example');
$workflow->save();
// Reload the French version of the node.
$node = Node::load($nid);
$node_fr = $node->getTranslation('fr');
/** @var \Drupal\node\NodeInterface $node_fr */
$node_fr->setTitle('Nouveau');
$node_fr->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.