You are here

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

Tests that moderation states are correctly cleared.

Parameters

array $expectations: (optional) The expectations to assert. See ::createRevisions() for info.

1 call to TestBase::testClear()
TestBase::testRestore in tests/src/Kernel/Migration/TestBase.php
Tests that moderation states are properly restored.

File

tests/src/Kernel/Migration/TestBase.php, line 115

Class

TestBase
Tests the save-clear-restore migration flow for a single entity type.

Namespace

Drupal\Tests\wbm2cm\Kernel\Migration

Code

public function testClear(array $expectations = NULL) {
  $expectations = $expectations ?: $this
    ->createRevisions();
  $this
    ->testSave($expectations);
  $this
    ->execute($this->storage
    ->getEntityTypeId(), 'clear');
  foreach ($expectations as $vid => $languages) {

    /** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
    $revision = $this->storage
      ->loadRevision($vid);
    foreach (array_keys($languages) as $language) {
      $this
        ->assertTrue($revision
        ->getTranslation($language)
        ->get('moderation_state')
        ->isEmpty());
    }
  }
}