The FieldConfig entity should have a dependency on the module that provides the entity type. So if you create a field on taxonomy terms then it will depend on the taxonomy module since the field has no meaning with the taxonomy module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott’s picture

Status: Active » Needs review
FileSize
7.33 KB

A patch to what is outlined in the summary.

alexpott’s picture

Berdir’s picture

+++ b/core/modules/field/tests/Drupal/field/Tests/FieldConfigEntityUnitTest.php
@@ -88,10 +84,34 @@ public function setUp() {
+    // Get definition is called three times. Twice in
+    // ConfigEntityBase::addDependency() to get the provider of the field config
+    // entity type and once in FieldConfig::calculateDependencies() to get the
+    // provider of the entity type that field is attached to.
+    $this->entityManager->expects($this->at(0))
+      ->method('getDefinition')
+      ->with($this->entityTypeId)
+      ->will($this->returnValue($fieldConfigentityType));
+    $this->entityManager->expects($this->at(1))
+      ->method('getDefinition')
+      ->with($this->entityTypeId)
+      ->will($this->returnValue($this->entityType));
+    $this->entityManager->expects($this->at(2))
+      ->method('getDefinition')
+      ->with($this->entityTypeId)
+      ->will($this->returnValue($fieldConfigentityType));

This is super-confusing. Can't we use two different entity type ID's if we need two different types? This doesn't seem like a realistic scenario, we could be calling it with the wrong ID or something?

alexpott’s picture

FileSize
3.3 KB
8.03 KB

Good point.

xjm’s picture

Issue tags: +Configuration system
Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yes, now the test makes much more sense :)

I guess it would also be possible to solve getDefinition() with a $this->returnValueMap(), but the explicit expectations and explanation of calls is in this case is OK I think. (It sometimes is too strict and makes internal refactoring painful...)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 94bdf61 on 8.x by catch:
    Issue #2232597 by alexpott: FieldConfig does not depend on the module...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.