function ContentModerationStateTest::testModerationWithFieldConfigOverride
Same name in other branches
- 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testModerationWithFieldConfigOverride()
- 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testModerationWithFieldConfigOverride()
- 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testModerationWithFieldConfigOverride()
Tests moderation when the moderation_state field has a config override.
1 method overrides ContentModerationStateTest::testModerationWithFieldConfigOverride()
- WorkspacesContentModerationStateTest::testModerationWithFieldConfigOverride in core/
modules/ content_moderation/ tests/ src/ Kernel/ WorkspacesContentModerationStateTest.php - Tests moderation when the moderation_state field has a config override.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php, line 423
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testModerationWithFieldConfigOverride() {
$this->createContentType([
'type' => 'test_type',
]);
$workflow = $this->createEditorialWorkflow();
$this->addEntityTypeAndBundleToWorkflow($workflow, 'node', 'test_type');
$fields = $this->container
->get('entity_field.manager')
->getFieldDefinitions('node', 'test_type');
$field_config = $fields['moderation_state']->getConfig('test_type');
$field_config->setLabel('Field Override!');
$field_config->save();
$node = Node::create([
'title' => 'Test node',
'type' => 'test_type',
]);
$node->save();
$this->assertFalse($node->isPublished());
$this->assertEquals('draft', $node->moderation_state->value);
$node->moderation_state = 'published';
$node->save();
$this->assertTrue($node->isPublished());
$this->assertEquals('published', $node->moderation_state->value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.