Commit 69555bcd authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2884715 by timmillwood, Sam152, larowlan, tstoeckler: Initial Content...

Issue #2884715 by timmillwood, Sam152, larowlan, tstoeckler: Initial Content Moderation transitions are not correct
parent 985c26a3
......@@ -331,7 +331,7 @@ public function getConfiguration() {
*/
public function getInitialState(WorkflowInterface $workflow, $entity = NULL) {
if ($entity instanceof EntityPublishedInterface) {
return $workflow->getState($entity->isPublished() ? 'published' : 'draft');
return $workflow->getState($entity->isPublished() && !$entity->isNew() ? 'published' : 'draft');
}
return parent::getInitialState($workflow);
}
......
......@@ -77,6 +77,12 @@ public function testInitialState() {
$this->assertEquals('draft', $loaded_unpublished_node->moderation_state->value);
$this->assertEquals('published', $loaded_published_node->moderation_state->value);
$this->assertEquals('draft', $loaded_entity_test->moderation_state->value);
$presave_node = Node::create([
'type' => 'example',
'title' => 'Presave node',
]);
$this->assertEquals('draft', $presave_node->moderation_state->value);
}
}
......@@ -64,7 +64,8 @@ protected function setUp() {
* Test the field item list when accessing an index.
*/
public function testArrayIndex() {
$this->assertEquals('published', $this->testNode->moderation_state[0]->value);
$this->assertFalse($this->testNode->isPublished());
$this->assertEquals('draft', $this->testNode->moderation_state[0]->value);
}
/**
......@@ -75,7 +76,7 @@ public function testArrayIteration() {
foreach ($this->testNode->moderation_state as $item) {
$states[] = $item->value;
}
$this->assertEquals(['published'], $states);
$this->assertEquals(['draft'], $states);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment