You are here

public function EntityStateChangeValidationTest::testValidTransition in Workbench Moderation 8

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

Test valid transitions.

@covers ::validate

File

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

Class

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

Namespace

Drupal\Tests\workbench_moderation\Kernel

Code

public function testValidTransition() {
  $this
    ->setCurrentUser($this->adminUser);
  $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());
}