public function EntityStateChangeValidationTest::testValidTransition in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testValidTransition()
- 9 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::testValidTransition()
Tests valid transitions.
@covers ::validate
File
- core/
modules/ content_moderation/ tests/ src/ Kernel/ EntityStateChangeValidationTest.php, line 62
Class
- EntityStateChangeValidationTest
- @coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator @group content_moderation
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testValidTransition() {
$this
->setCurrentUser($this->adminUser);
$node_type = NodeType::create([
'type' => 'example',
]);
$node_type
->save();
$workflow = $this
->createEditorialWorkflow();
$workflow
->getTypePlugin()
->addEntityTypeAndBundle('node', 'example');
$workflow
->save();
$node = Node::create([
'type' => 'example',
'title' => 'Test title',
]);
$node->moderation_state->value = 'draft';
$node
->save();
$node->moderation_state->value = 'published';
$this
->assertCount(0, $node
->validate());
$node
->save();
$this
->assertEquals('published', $node->moderation_state->value);
}