+ $this->assertModerationState($latest_revision->getRevisionId(), $latest_revision->language()->getId(), 'draft');
+ }
+
+ /**
+ * Verifies the expected moderation state revision exists.
+ *
+ * @param int $revision_id
+ * The revision ID of the host entity.
+ * @param string $langcode
+ * The language code of the host entity to check.
+ * @param string $expected_state
+ * The state the content moderation state revision should be in.
+ * @param string $expected_workflow
+ * The workflow the content moderation state revision should be using.
+ */
+ protected function assertModerationState($revision_id, $langcode, $expected_state, $expected_workflow = 'editorial') {
+ $moderation_state_storage = $this->entityTypeManager->getStorage('content_moderation_state');
+
+ $query = $moderation_state_storage->getQuery();
+ $results = $query->allRevisions()
+ ->condition('content_entity_revision_id', $revision_id)
+ ->condition('langcode', $langcode)
+ ->execute();
+ $this->assertCount(1, $results);
+
+ $moderation_state = $moderation_state_storage
+ ->loadRevision(key($results))
+ ->getTranslation($langcode);
+ $this->assertEquals($expected_state, $moderation_state->get('moderation_state')->value);
+ $this->assertEquals($expected_workflow, $moderation_state->get('workflow')->target_id);