trait EntityDefinitionTestTrait (View source)

deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait.

Provides some test methods used to update existing entity definitions.

Methods

enableNewEntityType()

Enables a new entity type definition.

resetEntityType()

Resets the entity type definition.

updateEntityTypeToRevisionable()

Updates the 'entity_test_update' entity type to revisionable.

updateEntityTypeToNotRevisionable()

Updates the 'entity_test_update' entity type not revisionable.

updateEntityTypeToTranslatable()

Updates the 'entity_test_update' entity type to translatable.

updateEntityTypeToNotTranslatable()

Updates the 'entity_test_update' entity type to not translatable.

updateEntityTypeToRevisionableAndTranslatable()

Updates the 'entity_test_update' entity type to revisionable and translatable.

addBaseField(string $type = 'string', string $entity_type_id = 'entity_test_update', bool $is_revisionable = FALSE)

Adds a new base field to the 'entity_test_update' entity type.

addLongNameBaseField()

Adds a long-named base field to the 'entity_test_update' entity type.

addRevisionableBaseField(string $type = 'string')

Adds a new revisionable base field to the 'entity_test_update' entity type.

modifyBaseField()

Modifies the new base field from 'string' to 'text'.

makeBaseFieldEntityKey()

Promotes a field to an entity key.

removeBaseField(string $entity_type_id = 'entity_test_update')

Removes the new base field from the 'entity_test_update' entity type.

addBaseFieldIndex()

Adds a single-field index to the base field.

removeBaseFieldIndex()

Removes the index added in addBaseFieldIndex().

addBundleField(string $type = 'string')

Adds a new bundle field to the 'entity_test_update' entity type.

modifyBundleField()

Modifies the new bundle field from 'string' to 'text'.

removeBundleField()

Removes the new bundle field from the 'entity_test_update' entity type.

addEntityIndex()

Adds an index to the 'entity_test_update' entity type's base table.

removeEntityIndex()

Removes the index added in addEntityIndex().

renameBaseTable()

Renames the base table to 'entity_test_update_new'.

renameDataTable()

Renames the data table to 'entity_test_update_data_new'.

renameRevisionBaseTable()

Renames the revision table to 'entity_test_update_revision_new'.

renameRevisionDataTable()

Renames the revision data table to 'entity_test_update_revision_data_new'.

deleteEntityType()

Removes the entity type.

Details

protected enableNewEntityType()

Enables a new entity type definition.

protected resetEntityType()

Resets the entity type definition.

protected updateEntityTypeToRevisionable()

Updates the 'entity_test_update' entity type to revisionable.

protected updateEntityTypeToNotRevisionable()

Updates the 'entity_test_update' entity type not revisionable.

protected updateEntityTypeToTranslatable()

Updates the 'entity_test_update' entity type to translatable.

protected updateEntityTypeToNotTranslatable()

Updates the 'entity_test_update' entity type to not translatable.

protected updateEntityTypeToRevisionableAndTranslatable()

Updates the 'entity_test_update' entity type to revisionable and translatable.

protected addBaseField(string $type = 'string', string $entity_type_id = 'entity_test_update', bool $is_revisionable = FALSE)

Adds a new base field to the 'entity_test_update' entity type.

Parameters

string $type

(optional) The field type for the new field. Defaults to 'string'.

string $entity_type_id

(optional) The entity type ID the base field should be attached to. Defaults to 'entity_test_update'.

bool $is_revisionable

(optional) If the base field should be revisionable or not. Defaults to FALSE.

protected addLongNameBaseField()

Adds a long-named base field to the 'entity_test_update' entity type.

protected addRevisionableBaseField(string $type = 'string')

Adds a new revisionable base field to the 'entity_test_update' entity type.

Parameters

string $type

(optional) The field type for the new field. Defaults to 'string'.

protected modifyBaseField()

Modifies the new base field from 'string' to 'text'.

protected makeBaseFieldEntityKey()

Promotes a field to an entity key.

protected removeBaseField(string $entity_type_id = 'entity_test_update')

Removes the new base field from the 'entity_test_update' entity type.

Parameters

string $entity_type_id

(optional) The entity type ID the base field should be attached to.

protected addBaseFieldIndex()

Adds a single-field index to the base field.

protected removeBaseFieldIndex()

Removes the index added in addBaseFieldIndex().

protected addBundleField(string $type = 'string')

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'.

protected modifyBundleField()

Modifies the new bundle field from 'string' to 'text'.

protected removeBundleField()

Removes the new bundle field from the 'entity_test_update' entity type.

protected addEntityIndex()

Adds an index to the 'entity_test_update' entity type's base table.

See also

\Drupal\entity_test\EntityTestStorageSchema::getEntitySchema()

protected removeEntityIndex()

Removes the index added in addEntityIndex().

protected renameBaseTable()

Renames the base table to 'entity_test_update_new'.

protected renameDataTable()

Renames the data table to 'entity_test_update_data_new'.

protected renameRevisionBaseTable()

Renames the revision table to 'entity_test_update_revision_new'.

protected renameRevisionDataTable()

Renames the revision data table to 'entity_test_update_revision_data_new'.

protected deleteEntityType()

Removes the entity type.