Issue #3025250 by Sam152, chr.fritsch: BaseFieldDefinition::getProvider() always returns 'content_moderation'

8.7.x
Alex Pott 2019-01-21 18:22:56 +00:00
parent d6688ebf3c
commit 6077050ec7
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 22 additions and 1 deletions

View File

@ -77,7 +77,9 @@ function content_moderation_entity_bundle_field_info(EntityTypeInterface $entity
// information to the field definition allows the associated workflow to be
// derived where a field definition is present.
$base_field_definitions['moderation_state']->setTargetBundle($bundle);
return $base_field_definitions;
return [
'moderation_state' => $base_field_definitions['moderation_state'],
];
}
}

View File

@ -42,6 +42,13 @@ class EntityTypeInfoTest extends KernelTestBase {
*/
protected $entityTypeInfo;
/**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager;
/**
* {@inheritdoc}
*/
@ -50,6 +57,7 @@ class EntityTypeInfoTest extends KernelTestBase {
$this->entityTypeInfo = $this->container->get('class_resolver')->getInstanceFromDefinition(EntityTypeInfo::class);
$this->entityTypeManager = $this->container->get('entity_type.manager');
$this->entityFieldManager = $this->container->get('entity_field.manager');
$this->installConfig(['content_moderation']);
}
@ -120,6 +128,17 @@ class EntityTypeInfoTest extends KernelTestBase {
$this->assertTrue(isset($base_fields['moderation_state']));
}
/**
* Test entity base field provider.
*/
public function testEntityBaseFieldProvider() {
$this->enableModeration('entity_test_mulrev', 'entity_test_mulrev');
$this->container->get('state')->set('entity_test.field_test_item', TRUE);
$field_definitions = $this->entityFieldManager->getFieldDefinitions('entity_test_mulrev', 'entity_test_mulrev');
$this->assertEquals('entity_test', $field_definitions['field_test_item']->getProvider());
}
/**
* Add moderation to an entity type and bundle.
*/