public function EntityStateChangeValidationTest::testTransitionAccessValidationNewEntity in Workbench Moderation 8
Test transistion access validation on new entity creation.
@dataProvider transitionAccessValidationTestCases
File
- tests/
src/ Kernel/ EntityStateChangeValidationTest.php, line 195
Class
- EntityStateChangeValidationTest
- @coversDefaultClass \Drupal\workbench_moderation\Plugin\Validation\Constraint\ModerationStateValidator @group workbench_moderation
Namespace
Drupal\Tests\workbench_moderation\KernelCode
public function testTransitionAccessValidationNewEntity($permissions, $default_state, $target_state, $messages) {
$this
->setCurrentUser($this
->createUser($permissions));
$this
->createExampleModeratedContentType($default_state, [
'draft',
'needs_review',
'published',
'archived',
]);
$node = Node::create([
'type' => 'example',
'title' => 'Test content',
'moderation_state' => $target_state,
]);
$this
->assertTrue($node
->isNew());
$violations = $node
->validate();
$this
->assertCount(count($messages), $violations);
foreach ($messages as $i => $message) {
$this
->assertEquals($message, $violations
->get($i)
->getMessage());
}
}