Update to Drupal 8.2.1. For more information, see https://www.drupal.org/project/drupal/releases/8.2.1
This commit is contained in:
parent
f1c8716f57
commit
23ffed3665
9 changed files with 227 additions and 2 deletions
|
@ -23,6 +23,10 @@ class ModerationStateFieldItemList extends EntityReferenceFieldItemList {
|
|||
protected function getModerationState() {
|
||||
$entity = $this->getEntity();
|
||||
|
||||
if (!\Drupal::service('content_moderation.moderation_information')->shouldModerateEntitiesOfBundle($entity->getEntityType(), $entity->bundle())) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($entity->id() && $entity->getRevisionId()) {
|
||||
$revisions = \Drupal::service('entity.query')->get('content_moderation_state')
|
||||
->condition('content_entity_type_id', $entity->getEntityTypeId())
|
||||
|
|
|
@ -47,6 +47,7 @@ class ModerationStateNodeTest extends ModerationStateTestBase {
|
|||
}
|
||||
|
||||
$node = reset($nodes);
|
||||
$this->assertEqual('draft', $node->moderation_state->target_id);
|
||||
|
||||
$path = 'node/' . $node->id() . '/edit';
|
||||
// Set up published revision.
|
||||
|
@ -55,6 +56,7 @@ class ModerationStateNodeTest extends ModerationStateTestBase {
|
|||
/* @var \Drupal\node\NodeInterface $node */
|
||||
$node = \Drupal::entityTypeManager()->getStorage('node')->load($node->id());
|
||||
$this->assertTrue($node->isPublished());
|
||||
$this->assertEqual('published', $node->moderation_state->target_id);
|
||||
|
||||
// Verify that the state field is not shown.
|
||||
$this->assertNoText('Published');
|
||||
|
@ -62,6 +64,31 @@ class ModerationStateNodeTest extends ModerationStateTestBase {
|
|||
// Delete the node.
|
||||
$this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
|
||||
$this->assertText(t('The Moderated content moderated content has been deleted.'));
|
||||
|
||||
$this->drupalGet('admin/structure/types/manage/moderated_content/moderation');
|
||||
$this->assertFieldByName('enable_moderation_state');
|
||||
$this->assertFieldChecked('edit-enable-moderation-state');
|
||||
$this->drupalPostForm(NULL, ['enable_moderation_state' => FALSE], t('Save'));
|
||||
$this->drupalGet('admin/structure/types/manage/moderated_content/moderation');
|
||||
$this->assertFieldByName('enable_moderation_state');
|
||||
$this->assertNoFieldChecked('edit-enable-moderation-state');
|
||||
$this->drupalPostForm('node/add/moderated_content', [
|
||||
'title[0][value]' => 'non-moderated content',
|
||||
], t('Save and publish'));
|
||||
|
||||
$nodes = \Drupal::entityTypeManager()
|
||||
->getStorage('node')
|
||||
->loadByProperties([
|
||||
'title' => 'non-moderated content',
|
||||
]);
|
||||
|
||||
if (!$nodes) {
|
||||
$this->fail('Non-moderated test node was not saved correctly.');
|
||||
return;
|
||||
}
|
||||
|
||||
$node = reset($nodes);
|
||||
$this->assertEqual(NULL, $node->moderation_state->target_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue