function entity_test_create_bundle in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_create_bundle()
Creates a new bundle for entity_test entities.
Parameters
string $bundle: The machine-readable name of the bundle.
string $text: (optional) The human-readable name of the bundle. If none is provided, the machine name will be used.
string $entity_type: (optional) The entity type for which the bundle is created. Defaults to 'entity_test'.
24 calls to entity_test_create_bundle()
- BulkDeleteTest::setUp in core/
modules/ field/ src/ Tests/ BulkDeleteTest.php - Set the default field storage backend for fields created during tests.
- CommentCacheTagsTest::createEntity in core/
modules/ comment/ src/ Tests/ CommentCacheTagsTest.php - Creates the entity to be tested.
- CommentNonNodeTest::setUp in core/
modules/ comment/ src/ Tests/ CommentNonNodeTest.php - Sets up a Drupal site for running functional and integration tests.
- CommentNonNodeTest::testsNonIntegerIdEntities in core/
modules/ comment/ src/ Tests/ CommentNonNodeTest.php - Tests comment fields cannot be added to entity types without integer IDs.
- ConfigTranslationUiTest::testFieldConfigTranslation in core/
modules/ config_translation/ src/ Tests/ ConfigTranslationUiTest.php - Tests the translation of field and field storage configuration.
File
- core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module, line 165 - Test module for the entity API providing several entity types for testing.
Code
function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity_test') {
$bundles = \Drupal::state()
->get($entity_type . '.bundles') ?: array(
$entity_type => array(
'label' => 'Entity Test Bundle',
),
);
$bundles += array(
$bundle => array(
'label' => $text ? $text : $bundle,
),
);
\Drupal::state()
->set($entity_type . '.bundles', $bundles);
\Drupal::entityManager()
->onBundleCreate($bundle, $entity_type);
}