You are here

protected function ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList in Drupal 9

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

Assert the set of expectations when the moderation state field is emptied.

5 calls to ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList()
ModerationStateFieldItemListTest::testAssignNullItemList in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Tests the field item when it is assigned NULL.
ModerationStateFieldItemListTest::testEmptyFieldItem in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Tests an empty value assigned to the field item.
ModerationStateFieldItemListTest::testEmptyFieldItemList in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Tests an empty value assigned to the field item list.
ModerationStateFieldItemListTest::testEmptyStateAndAppend in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Tests the item list when it is emptied and appended to.
ModerationStateFieldItemListTest::testUnsetItemList in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Tests the field item when it is unset.

File

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

Class

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

Namespace

Drupal\Tests\content_moderation\Kernel

Code

protected function assertEmptiedModerationFieldItemList() {
  $this
    ->assertTrue($this->testNode->moderation_state
    ->isEmpty());

  // Test the empty value causes a violation in the entity.
  $violations = $this->testNode
    ->validate();
  $this
    ->assertCount(1, $violations);
  $this
    ->assertEquals('This value should not be null.', $violations
    ->get(0)
    ->getMessage());

  // Test that incorrectly saving the entity regardless will not produce a
  // change in the moderation state.
  $this->testNode
    ->save();
  $this
    ->assertEquals('draft', Node::load($this->testNode
    ->id())->moderation_state->value);
}