function ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php \Drupal\Tests\content_moderation\Kernel\ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList()
  2. 10 core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php \Drupal\Tests\content_moderation\Kernel\ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList()
  3. 11.x 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
Test the field item when it is assigned NULL.
ModerationStateFieldItemListTest::testEmptyFieldItem in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Test an empty value assigned to the field item.
ModerationStateFieldItemListTest::testEmptyFieldItemList in core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php
Test 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
Test the field item when it is unset.

File

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

Class

ModerationStateFieldItemListTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21content_moderation%21src%21Plugin%21Field%21ModerationStateFieldItemList.php/class/ModerationStateFieldItemList/8.9.x" title="A computed field that provides a content entity&#039;s moderation state." class="local">\Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList</a>

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.