Loading core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php +8 −0 Original line number Diff line number Diff line Loading @@ -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. } } core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php +20 −0 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -17,6 +18,7 @@ class ModerationStateFieldItemListTest extends KernelTestBase { use ContentModerationTestTrait; use UserCreationTrait; /** * {@inheritdoc} Loading @@ -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'); Loading Loading @@ -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. */ Loading Loading
core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php +8 −0 Original line number Diff line number Diff line Loading @@ -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. } }
core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php +20 −0 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -17,6 +18,7 @@ class ModerationStateFieldItemListTest extends KernelTestBase { use ContentModerationTestTrait; use UserCreationTrait; /** * {@inheritdoc} Loading @@ -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'); Loading Loading @@ -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. */ Loading