X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FTests%2FEntity%2FEntityDefinitionTestTrait.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FTests%2FEntity%2FEntityDefinitionTestTrait.php;h=380c1e66eda4ddad346cce50d3cfe8c19bf0ad35;hp=3b1e7bd6601ae4b1d32dd1eb9f567be8f10e26e5;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php b/web/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php index 3b1e7bd66..380c1e66e 100644 --- a/web/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php +++ b/web/core/modules/system/src/Tests/Entity/EntityDefinitionTestTrait.php @@ -111,12 +111,19 @@ trait EntityDefinitionTestTrait { * * @param string $type * (optional) The field type for the new field. Defaults to 'string'. + * @param string $entity_type_id + * (optional) The entity type ID the base field should be attached to. + * Defaults to 'entity_test_update'. + * @param bool $is_revisionable + * (optional) If the base field should be revisionable or not. Defaults to + * FALSE. */ - protected function addBaseField($type = 'string') { + protected function addBaseField($type = 'string', $entity_type_id = 'entity_test_update', $is_revisionable = FALSE) { $definitions['new_base_field'] = BaseFieldDefinition::create($type) ->setName('new_base_field') + ->setRevisionable($is_revisionable) ->setLabel(t('A new base field')); - $this->state->set('entity_test_update.additional_base_field_definitions', $definitions); + $this->state->set($entity_type_id . '.additional_base_field_definitions', $definitions); } /** @@ -167,9 +174,12 @@ trait EntityDefinitionTestTrait { /** * Removes the new base field from the 'entity_test_update' entity type. + * + * @param string $entity_type_id + * (optional) The entity type ID the base field should be attached to. */ - protected function removeBaseField() { - $this->state->delete('entity_test_update.additional_base_field_definitions'); + protected function removeBaseField($entity_type_id = 'entity_test_update') { + $this->state->delete($entity_type_id . '.additional_base_field_definitions'); } /**