public function EntityStateChangeValidationTest::testLegacyMultilingualContent in Workbench Moderation 8.2
Verifies that content without prior moderation information can be translated.
File
- tests/
src/ Kernel/ EntityStateChangeValidationTest.php, line 120
Class
- EntityStateChangeValidationTest
- @coversDefaultClass \Drupal\workbench_moderation\Plugin\Validation\Constraint\ModerationStateValidator @group workbench_moderation
Namespace
Drupal\Tests\workbench_moderation\KernelCode
public function testLegacyMultilingualContent() {
// Enable French
ConfigurableLanguage::createFromLangcode('fr')
->save();
$node_type = NodeType::create([
'type' => 'example',
]);
$node_type
->save();
/** @var 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.
/** @var NodeType $node_type */
$node_type = NodeType::load('example');
$node_type
->setThirdPartySetting('workbench_moderation', 'enabled', TRUE);
$node_type
->setThirdPartySetting('workbench_moderation', 'allowed_moderation_states', [
'draft',
'needs_review',
'published',
]);
$node_type
->setThirdPartySetting('workbench_moderation', 'default_moderation_state', 'draft');
$node_type
->save();
// Reload the French version of the node.
$node = Node::load($nid);
$node_fr = $node
->getTranslation('fr');
/** @var NodeInterface $node_fr */
$node_fr
->setTitle('Nouveau');
$node_fr
->save();
}