public function UnPublishedStateConstraintTest::testInvalidPublishStateToUnPublishStateTransition in Scheduler content moderation integration 8
Test invalid transition.
Test invalid transition from scheduled published to scheduled un-published state.
@covers ::validate
File
- tests/
src/ Kernel/ UnPublishedStateConstraintTest.php, line 81
Class
- UnPublishedStateConstraintTest
- Test covering the UnPublishedStateConstraintValidator.
Namespace
Drupal\Tests\scheduler_content_moderation_integration\KernelCode
public function testInvalidPublishStateToUnPublishStateTransition() {
$this->workflow
->getTypePlugin()
->addState('published_2', 'Published 2')
->addTransition('published_2', 'Published 2', [
'draft',
], 'published_2');
$config = $this->workflow
->getTypePlugin()
->getConfiguration();
$config['states']['published_2']['published'] = TRUE;
$config['states']['published_2']['default_revision'] = TRUE;
$this->workflow
->getTypePlugin()
->setConfiguration($config);
$this->workflow
->save();
$node = Node::create([
'type' => 'example',
'title' => 'Test title',
'moderation_state' => 'draft',
'publish_on' => strtotime('tomorrow'),
'unpublish_on' => strtotime('+2 days'),
'unpublish_state' => 'archived',
'publish_state' => 'published_2',
]);
$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 scheduled publishing state of <em class="placeholder">published_2</em>.', $violations
->get(0)
->getMessage());
}