You are here

public function EntityStateChangeValidationTest::testValidTransition in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\workbench_moderation\Kernel\EntityStateChangeValidationTest::testValidTransition()

Test valid transitions.

@covers ::validate

File

tests/src/Kernel/EntityStateChangeValidationTest.php, line 39

Class

EntityStateChangeValidationTest
@coversDefaultClass \Drupal\workbench_moderation\Plugin\Validation\Constraint\ModerationStateValidator @group workbench_moderation

Namespace

Drupal\Tests\workbench_moderation\Kernel

Code

public function testValidTransition() {
  $node_type = NodeType::create([
    'type' => 'example',
  ]);
  $node_type
    ->save();
  $node = Node::create([
    'type' => 'example',
    'title' => 'Test title',
    'moderation_state' => 'draft',
  ]);
  $node
    ->save();
  $node->moderation_state->target_id = 'needs_review';
  $this
    ->assertCount(0, $node
    ->validate());
}