function EntityStateChangeValidationTest::testExistingContentWithNoModeration
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testExistingContentWithNoModeration()
- 8.9.x core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testExistingContentWithNoModeration()
- 10 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testExistingContentWithNoModeration()
Tests that content without prior moderation information can be moderated.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ EntityStateChangeValidationTest.php, line 255
Class
- EntityStateChangeValidationTest
- @coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator @group content_moderation
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testExistingContentWithNoModeration() : void {
$node_type = NodeType::create([
'type' => 'example',
'name' => 'Example',
]);
$node_type->save();
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create([
'type' => 'example',
'title' => 'Test title',
]);
$node->save();
$nid = $node->id();
// Enable moderation for our node type.
$workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()
->addEntityTypeAndBundle('node', 'example');
$workflow->save();
$this->setCurrentUser($this->createUser([
'use editorial transition publish',
]));
$node = Node::load($nid);
// Having no previous state should not break validation.
$violations = $node->validate();
$this->assertCount(0, $violations);
// Having no previous state should not break saving the node.
$node->setTitle('New');
$node->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.