function field_test_create_bundle

Creates a new bundle for test_entity entities.

Parameters

$bundle: The machine-readable name of the bundle.

$text: The human-readable name of the bundle. If none is provided, the machine name will be used.

7 calls to field_test_create_bundle()
BulkDeleteTest::setUp in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Set the default field storage backend for fields created during tests.
EntityQueryTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
Sets up a Drupal site for running functional and integration tests.
FieldAttachOtherTest::testFieldAttachPrepareViewMultiple in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
Tests the 'multiple entity' behavior of field_attach_prepare_view().
FieldAttachStorageTest::testFieldAttachCreateRenameBundle in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test field_attach_create_bundle() and field_attach_rename_bundle().
FieldAttachStorageTest::testFieldAttachDeleteBundle in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test field_attach_delete_bundle().

... See full list

File

drupal/core/modules/field/tests/modules/field_test/field_test.entity.inc, line 66
Defines an entity type.

Code

function field_test_create_bundle($bundle, $text = NULL) {
  $bundles = state()
    ->get('field_test.bundles') ?: array(
    'test_bundle' => array(
      'label' => 'Test Bundle',
    ),
  );
  $bundles += array(
    $bundle => array(
      'label' => $text ? $text : $bundle,
    ),
  );
  state()
    ->set('field_test.bundles', $bundles);
  $info = entity_get_info();
  foreach ($info as $type => $type_info) {
    if ($type_info['module'] == 'field_test') {
      field_attach_create_bundle($type, $bundle);
    }
  }
}