function ContentModerationSyncingTest::testMultipleRevisionStateChangedDuringSync
Tests state changes with multiple revisions during a sync.
File
- 
              core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationSyncingTest.php, line 91  
Class
- ContentModerationSyncingTest
 - Test content moderation when an entity is marked as 'syncing'.
 
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testMultipleRevisionStateChangedDuringSync() : void {
  $entity = EntityTestMulRevPub::create([
    'moderation_state' => 'published',
    'name' => 'foo',
  ]);
  $entity->save();
  $entity->name = 'bar';
  $entity->save();
  $latest_revision_id = $entity->getRevisionId();
  $entity->setSyncing(TRUE);
  $entity->moderation_state = 'draft';
  $entity->save();
  $this->assertEquals($latest_revision_id, $entity->getRevisionId());
  $this->assertEquals('draft', $entity->moderation_state->value);
  $this->assertEquals('bar', $entity->name->value);
  // The default revision will not automatically be assigned to another
  // revision, so a draft unpublished revision will be created when syncing
  // 'published' to 'draft'.
  $this->assertFalse($entity->isPublished());
  $this->assertTrue($entity->isDefaultRevision());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.