function ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList
Same name and namespace in other branches
- 11.x core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php \Drupal\Tests\content_moderation\Kernel\ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList()
- 10 core/modules/content_moderation/tests/src/Kernel/ModerationStateFieldItemListTest.php \Drupal\Tests\content_moderation\Kernel\ModerationStateFieldItemListTest::assertEmptiedModerationFieldItemList()
- 8.9.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.
@internal
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ModerationStateFieldItemListTest.php, line 168
Class
- ModerationStateFieldItemListTest
- @coversDefaultClass \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList[[api-linebreak]]
Namespace
Drupal\Tests\content_moderation\KernelCode
protected function assertEmptiedModerationFieldItemList() : void {
$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.