Skip to content
Snippets Groups Projects
Unverified Commit 486bab8b authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3048962 by Sam152, anmolgoyal74, paulocs, EclipseGc, abarrios,...

Issue #3048962 by Sam152, anmolgoyal74, paulocs, EclipseGc, abarrios, scotwith1t, Lendude: Moderation State fields generate bad sample data
parent 36b600e4
Branches
Tags
7 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage"
......@@ -174,4 +174,12 @@ protected function updateModeratedEntity($moderation_state_id) {
}
}
/**
* {@inheritdoc}
*/
public function generateSampleItems($count = 1) {
// No sample items generated since the starting moderation state is always
// computed based on the default state of the associated workflow.
}
}
......@@ -7,6 +7,7 @@
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\workflows\Entity\Workflow;
/**
......@@ -17,6 +18,7 @@
class ModerationStateFieldItemListTest extends KernelTestBase {
use ContentModerationTestTrait;
use UserCreationTrait;
/**
* {@inheritdoc}
......@@ -42,6 +44,7 @@ protected function setUp(): void {
parent::setUp();
$this->installSchema('node', 'node_access');
$this->installSchema('system', 'sequences');
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installEntitySchema('content_moderation_state');
......@@ -401,6 +404,23 @@ public function testWithExistingUnmoderatedContent() {
$this->assertEquals('published', $translation->moderation_state->value);
}
/**
* Test generating sample values for entities with a moderation state.
*/
public function testModerationStateSampleValues() {
$this->container->get('current_user')->setAccount(
$this->createUser([
'use editorial transition create_new_draft',
'use editorial transition publish',
])
);
$sample = $this->container->get('entity_type.manager')
->getStorage('node')
->createWithSampleValues('example');
$this->assertCount(0, $sample->validate());
$this->assertEquals('draft', $sample->moderation_state->value);
}
/**
* Tests field item list translation support with unmoderated content.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment