function entity_test_delete_bundle in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_delete_bundle()
Deletes a bundle for entity_test entities.
Parameters
string $bundle: The machine-readable name of the bundle to delete.
string $entity_type: (optional) The entity type for which the bundle is deleted. Defaults to 'entity_test'.
5 calls to entity_test_delete_bundle()
- ContentModerationStateTest::testWorkflowNonConfigBundleDependencies in core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php - Test the content moderation workflow dependencies for non-config bundles.
- EntityAddUITest::testAddPageWithoutBundleEntities in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityAddUITest.php - Tests the add page for an entity type not using bundle entities.
- EntityBundleFieldTest::testCustomBundleFieldUsage in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityBundleFieldTest.php - Tests making use of a custom bundle field.
- EntityReferenceSettingsTest::testCustomTargetBundleDeletion in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceSettingsTest.php - Tests that deletions of custom bundles are mirrored in field settings.
- FieldAttachStorageTest::testEntityDeleteBundle in core/
modules/ field/ tests/ src/ Kernel/ FieldAttachStorageTest.php - Test entity_bundle_delete().
File
- core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module, line 213 - Test module for the entity API providing several entity types for testing.
Code
function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
$bundles = \Drupal::state()
->get($entity_type . '.bundles') ?: [
$entity_type => [
'label' => 'Entity Test Bundle',
],
];
unset($bundles[$bundle]);
\Drupal::state()
->set($entity_type . '.bundles', $bundles);
\Drupal::service('entity_bundle.listener')
->onBundleDelete($bundle, $entity_type);
}