public function ContentModerationStateTest::testWorkflowDependencies in Drupal 9
Same name and namespace in other branches
- 8 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::testWorkflowDependencies()
Tests the dependencies of the workflow when using content moderation.
1 method overrides ContentModerationStateTest::testWorkflowDependencies()
- WorkspacesContentModerationStateTest::testWorkflowDependencies in core/
modules/ content_moderation/ tests/ src/ Kernel/ WorkspacesContentModerationStateTest.php - Tests the dependencies of the workflow when using content moderation.
File
- core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php, line 575
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
public function testWorkflowDependencies() {
$node_type = $this
->createContentType([
'type' => 'example',
]);
$workflow = $this
->createEditorialWorkflow();
// Test both a config and non-config based bundle and entity type.
$this
->addEntityTypeAndBundleToWorkflow($workflow, 'node', 'example');
$this
->addEntityTypeAndBundleToWorkflow($workflow, 'entity_test_rev', 'entity_test_rev');
$this
->addEntityTypeAndBundleToWorkflow($workflow, 'entity_test_no_bundle', 'entity_test_no_bundle');
$this
->assertEquals([
'module' => [
'content_moderation',
'entity_test',
],
'config' => [
'node.type.example',
],
], $workflow
->getDependencies());
$this
->assertEquals([
'entity_test_no_bundle',
'entity_test_rev',
'node',
], $workflow
->getTypePlugin()
->getEntityTypes());
// Delete the node type and ensure it is removed from the workflow.
$node_type
->delete();
$workflow = Workflow::load('editorial');
$entity_types = $workflow
->getTypePlugin()
->getEntityTypes();
$this
->assertNotContains('node', $entity_types);
// Uninstall entity test and ensure it's removed from the workflow.
$this->container
->get('config.manager')
->uninstall('module', 'entity_test');
$workflow = Workflow::load('editorial');
$entity_types = $workflow
->getTypePlugin()
->getEntityTypes();
$this
->assertEquals([], $entity_types);
}