You are here

public function UnPublishedStateConstraintTest::testInvalidUnPublishStateTransition in Scheduler content moderation integration 8

Test an invalid un-publish transition.

Test an invalid un-publish transition from a nodes current moderation state.

@cover ::validate

File

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

Class

UnPublishedStateConstraintTest
Test covering the UnPublishedStateConstraintValidator.

Namespace

Drupal\Tests\scheduler_content_moderation_integration\Kernel

Code

public function testInvalidUnPublishStateTransition() {
  $node = Node::create([
    'type' => 'example',
    'title' => 'Test title',
    'moderation_state' => 'draft',
    'unpublish_on' => strtotime('tomorrow'),
    'unpublish_state' => 'archived',
  ]);
  $violations = $node
    ->validate();
  $this
    ->assertCount(1, $violations);
  $this
    ->assertEquals('The scheduled un-publishing state of <em class="placeholder">archived</em> is not a valid transition from the current moderation state of <em class="placeholder">draft</em> for this content.', $violations
    ->get(0)
    ->getMessage());
}