You are here

public function TestBase::testSingleTranslatedRevision in Workbench Moderation to Content Moderation 8.2

Migrates an entity with translations, but only one revision.

File

tests/src/Functional/TestBase.php, line 140

Class

TestBase

Namespace

Drupal\Tests\wbm2cm\Functional

Code

public function testSingleTranslatedRevision() {
  $entity = $this
    ->createEntity();
  $states = [
    'en' => $this
      ->randomEntity('moderation_state'),
    'fr' => $this
      ->randomEntity('moderation_state'),
    'hu' => $this
      ->randomEntity('moderation_state'),
  ];
  foreach ($states as $language => $state) {
    $this
      ->translate($entity, $language)
      ->set('moderation_state', $state);
  }
  $this->storage
    ->save($entity);
  $this
    ->doMigration();

  /** @var ContentEntityInterface $entity */
  $entity = $this->storage
    ->load($entity
    ->id());
  foreach ($states as $language => $state) {

    // The only revision should also be the default revision.
    $this
      ->assertTrue($entity
      ->isDefaultRevision());
    $this
      ->assertSame($state, $entity
      ->getTranslation($language)->moderation_state->value);
  }
}