protected function EntityDefinitionTestTrait::addBundleField in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php \Drupal\system\Tests\Entity\EntityDefinitionTestTrait::addBundleField()
Adds a new bundle field to the 'entity_test_update' entity type.
Parameters
string $type: (optional) The field type for the new field. Defaults to 'string'.
5 calls to EntityDefinitionTestTrait::addBundleField()
- EntityDefinitionTestTrait::modifyBundleField in core/modules/ system/ src/ Tests/ Entity/ EntityDefinitionTestTrait.php 
- Modifies the new bundle field from 'string' to 'text'.
- EntityDefinitionUpdateTest::testBundleFieldCreateDeleteWithExistingEntities in core/modules/ system/ src/ Tests/ Entity/ EntityDefinitionUpdateTest.php 
- Tests creating and deleting a bundle field if entities exist.
- EntityDefinitionUpdateTest::testBundleFieldCreateUpdateDeleteWithoutData in core/modules/ system/ src/ Tests/ Entity/ EntityDefinitionUpdateTest.php 
- Tests creating, updating, and deleting a bundle field if no entities exist.
- EntityDefinitionUpdateTest::testBundleFieldDeleteWithExistingData in core/modules/ system/ src/ Tests/ Entity/ EntityDefinitionUpdateTest.php 
- Tests deleting a bundle field when it has existing data.
- EntityDefinitionUpdateTest::testBundleFieldUpdateWithExistingData in core/modules/ system/ src/ Tests/ Entity/ EntityDefinitionUpdateTest.php 
- Tests updating a bundle field when it has existing data.
File
- core/modules/ system/ src/ Tests/ Entity/ EntityDefinitionTestTrait.php, line 180 
- Contains \Drupal\system\Tests\Entity\EntityDefinitionTestTrait.
Class
- EntityDefinitionTestTrait
- Provides some test methods used to update existing entity definitions.
Namespace
Drupal\system\Tests\EntityCode
protected function addBundleField($type = 'string') {
  $definitions['new_bundle_field'] = FieldStorageDefinition::create($type)
    ->setName('new_bundle_field')
    ->setLabel(t('A new bundle field'))
    ->setTargetEntityTypeId('entity_test_update');
  $this->state
    ->set('entity_test_update.additional_field_storage_definitions', $definitions);
  $this->state
    ->set('entity_test_update.additional_bundle_field_definitions.test_bundle', $definitions);
}