Unverified Commit ed9e93f5 authored by alexpott's avatar alexpott

Issue #2971157 by jhedstrom, Sam152: Moderation state set to default after entity is serialized

parent b989db1a
......@@ -141,11 +141,13 @@ public function onChange($delta) {
public function setValue($values, $notify = TRUE) {
parent::setValue($values, $notify);
if (isset($this->list[0])) {
$this->valueComputed = TRUE;
}
// If the parent created a field item and if the parent should be notified
// about the change (e.g. this is not initialized with the current value),
// update the moderated entity.
if (isset($this->list[0]) && $notify) {
$this->valueComputed = TRUE;
$this->updateModeratedEntity($this->list[0]->value);
}
}
......
......@@ -211,13 +211,39 @@ public function testEntityWithNoWorkflow() {
/**
* Test the moderation_state field after an entity has been serialized.
*
* @dataProvider entityUnserializeTestCases
*/
public function testEntityUnserialize() {
$this->testNode->moderation_state->value = 'draft';
public function testEntityUnserialize($state, $default, $published) {
$this->testNode->moderation_state->value = $state;
$this->assertEquals($state, $this->testNode->moderation_state->value);
$this->assertEquals($default, $this->testNode->isDefaultRevision());
$this->assertEquals($published, $this->testNode->isPublished());
$unserialized = unserialize(serialize($this->testNode));
$this->assertEquals('Test title', $unserialized->title->value);
$this->assertEquals('draft', $unserialized->moderation_state->value);
$this->assertEquals($state, $unserialized->moderation_state->value);
$this->assertEquals($default, $unserialized->isDefaultRevision());
$this->assertEquals($published, $unserialized->isPublished());
}
/**
* Test cases for ::testEntityUnserialize.
*/
public function entityUnserializeTestCases() {
return [
'Default draft state' => [
'draft',
TRUE,
FALSE,
],
'Non-default published state' => [
'published',
TRUE,
TRUE,
],
];
}
}
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