function ContentModerationWorkflowTypeApiTest::testRemoveEntityTypeAndBundle

Same name and namespace in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowTypeApiTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationWorkflowTypeApiTest::testRemoveEntityTypeAndBundle()
  2. 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowTypeApiTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationWorkflowTypeApiTest::testRemoveEntityTypeAndBundle()
  3. 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowTypeApiTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationWorkflowTypeApiTest::testRemoveEntityTypeAndBundle()

@covers ::addEntityTypeAndBundle @covers ::removeEntityTypeAndBundle

File

core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowTypeApiTest.php, line 105

Class

ContentModerationWorkflowTypeApiTest
Tests the API of the ContentModeration workflow type plugin.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testRemoveEntityTypeAndBundle() {
    
    /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration $workflow_plugin */
    $workflow_plugin = $this->workflow
        ->getTypePlugin();
    // There should be no bundles for fake_node to start with.
    $this->assertEquals([], $workflow_plugin->getBundlesForEntityType('fake_node'));
    // Removing a bundle which is not set on the workflow should not throw an
    // error and should still result in none being returned.
    $workflow_plugin->removeEntityTypeAndBundle('fake_node', 'fake_page');
    $this->assertEquals([], $workflow_plugin->getBundlesForEntityType('fake_node'));
    // Adding a bundle for fake_node should result it in being returned, but
    // then removing it will return no bundles for fake_node.
    $workflow_plugin->addEntityTypeAndBundle('fake_node', 'fake_page');
    $this->assertEquals([
        'fake_page',
    ], $workflow_plugin->getBundlesForEntityType('fake_node'));
    $workflow_plugin->removeEntityTypeAndBundle('fake_node', 'fake_page');
    $this->assertEquals([], $workflow_plugin->getBundlesForEntityType('fake_node'));
}

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