You are here

public function ModerationStateFieldItemListTest::testModerationStateSampleValues in Drupal 9

Same name and namespace in other branches
  1. 10 core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php \Drupal\Tests\content_moderation\Kernel\ModerationStateFieldItemListTest::testModerationStateSampleValues()

Test generating sample values for entities with a moderation state.

File

core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php, line 410

Class

ModerationStateFieldItemListTest
@coversDefaultClass \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList

Namespace

Drupal\Tests\content_moderation\Kernel

Code

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);
}