Unverified Commit e8a0c86a authored by alexpott's avatar alexpott

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

(cherry picked from commit 486bab8b)
parent 749fc09a
......@@ -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.
*/
......
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