public function CreateModeratedForwardRevisionTest::testCreateModeratedForwardRevision in Acquia Content Hub 8.2
Tests CreateModeratedForwardRevision event subscriber.
File
- tests/
src/ Kernel/ EventSubscriber/ ModeratedRevisions/ CreateModeratedForwardRevisionTest.php, line 96
Class
- CreateModeratedForwardRevisionTest
- Test that moderation state is correctly handled in PreEntitySave event.
Namespace
Drupal\Tests\acquia_contenthub\Kernel\EventSubscriber\PreEntitySaveCode
public function testCreateModeratedForwardRevision() {
$config_factory = $this->container
->get('config.factory');
$config = $config_factory
->getEditable('acquia_contenthub_moderation.settings');
$config
->set("workflows.{$this->workflow->id()}.moderation_state", 'archived');
$config
->save();
$stack = $this
->prophesize(DependencyStack::class);
$cdf = $this
->prophesize(CDFObject::class);
$event = new PreEntitySaveEvent($this->node, $stack
->reveal(), $cdf
->reveal());
$create_forward_revision = new CreateModeratedForwardRevision($this->container
->get('entity_type.manager'), $this->container
->get('config.factory'), $this->container
->get('content_moderation.moderation_information'), $this->container
->get('logger.factory'));
$mod_state = $this->node
->get('moderation_state')
->getString();
$this
->assertEqual('draft', $mod_state);
$create_forward_revision
->onPreEntitySave($event);
/** @var \Drupal\node\NodeInterface $entity */
$entity = $event
->getEntity();
$mod_state = $entity
->get('moderation_state')
->getString();
$this
->assertEqual('archived', $mod_state);
}