Unverified Commit 6077050e authored by alexpott's avatar alexpott

Issue #3025250 by Sam152, chr.fritsch: BaseFieldDefinition::getProvider()...

Issue #3025250 by Sam152, chr.fritsch: BaseFieldDefinition::getProvider() always returns 'content_moderation'
parent d6688ebf
......@@ -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'],
];
}
}
......
......@@ -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 @@ protected function setUp() {
$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 @@ public function testBaseFieldOnlyAddedToModeratedEntityTypes() {
$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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment