Skip to content

Commit

Permalink
Issue #3020387 by Sam152, luisnicg, bahuma20, jungle: Moderation stat…
Browse files Browse the repository at this point in the history
…e is the same for all node's translations in edit page

(cherry picked from commit 685f3a060ddaf3c78389fa275a63c7f0e9aa2f21)
  • Loading branch information
larowlan committed Jun 12, 2020
1 parent d585417 commit 4178bfe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected function loadContentModerationStateRevision(ContentEntityInterface $en
// being reverted.
->condition('content_entity_revision_id', $entity->isNewRevision() ? $entity->getLoadedRevisionId() : $entity->getRevisionId())
->condition('workflow', $moderation_info->getWorkflowForEntity($entity)->id())
->condition('langcode', $entity->language()->getId())
->allRevisions()
->sort('revision_id', 'DESC')
->execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,33 @@ public function testWithExistingUnmoderatedContent() {
$this->assertEquals('published', $translation->moderation_state->value);
}

/**
* Tests field item list translation support with unmoderated content.
*/
public function testTranslationWithExistingUnmoderatedContent() {
$node = Node::create([
'title' => 'Published en',
'langcode' => 'en',
'type' => 'unmoderated',
]);
$node->setPublished();
$node->save();

$workflow = Workflow::load('editorial');
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'unmoderated');
$workflow->save();

$translation = $node->addTranslation('de');
$translation->moderation_state = 'draft';
$translation->save();

$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$node = $node_storage->loadRevision($node_storage->getLatestRevisionId($node->id()));

$this->assertEquals('published', $node->moderation_state->value);
$this->assertEquals('draft', $translation->moderation_state->value);
$this->assertTrue($node->isPublished());
$this->assertFalse($translation->isPublished());
}

}

0 comments on commit 4178bfe

Please sign in to comment.