Follow-up from #1256368: Add 'visible' key to hook_field_extra_fields().

In D7 we don't have the 'visible' key available in hook_entity_extra_field_info(), whereas D8 does recognize it.

There is an issue open to add this key to D7, but in that issue it turned out that there are no tests for it. So this issue is dedicated to writing those tests and potentially backporting them to D7, while the other issue can focus on adding the key to D7.

Comments

kristiaanvandeneynde’s picture

Whoops, Dreditor...

kristiaanvandeneynde’s picture

Found it in D8! :)

The extra fields now use EntityDisplay objects along with regular fields: https://drupal.org/node/1875952

So I did some digging and found the D8 functionality in Drupal\field_ui\DisplayOverviewBase::buildExtraFieldRow(). See the code (line 447).

So it could very well be that there are tests already for D8, but that they now are more generic tests for EntityDisplay objects.

(Cross-posting in related issue)

andypost’s picture

Title: Write tests for 'visible' key in hook_field_extra_fields() » Write tests for 'visibility' of fields exposed with hook_entity_extra_field_info()
Issue summary: View changes
Issue tags: -Needs backport to D7 +Needs tests, +Entity Field API, +Novice, +Needs issue summary update

D7 has own issue, seems we need to test entity display and maybe for entity form

Tagged properly, novice:
1) check for tests of entity displays, extra fields now could be in 'content' or 'hidden' sections
2) make sure that both entity form and view displays are covered with tests

kunalgrover05’s picture

There are tests already in EntityDisplayTest class function testExtraFieldComponent() which executes test environment created by entity_test_entity_extra_field_info in entity_test.module, so partially the task is solved already.

To write the same tests for EntityFormDisplayTest we need to be able to load the same info for testing and create a form using that. How to do that?

cilefen’s picture

@kunalgrover05 Thank you for working on this issue. EntityFormDisplayTest already activates the entity_test module so the procedure will be quite similar.

David_Rothstein’s picture

Seems like the testExtraFieldComponent() method mentioned above does already test this to some extent, since it has this code:

    // Check that the default visibility taken into account for extra fields
    // unknown in the display.
    $this->assertEqual($display->getComponent('display_extra_field'), array('weight' => 5));
    $this->assertNull($display->getComponent('display_extra_field_hidden'));

where the test module implements hook_entity_extra_field_info() to mark the first one with 'visible' => TRUE and the second with 'visible' => FALSE.

jp.stacey’s picture

Issue tags: +SprintWeekend2016

Looking at this as part of SprintWeekend2016.

jp.stacey’s picture

Status: Active » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.48 KB

I agree with @David_Rothstein that this is implicitly tested already, but the tests for: how a visible field works; how a non-visible field works; what modifying them with setComponent() does.... It's all coupled together, so more granularity of testing might be good.

For comment, and to move this issue along, attached is a patch which splits testExtraFieldComponent() up, adding a new test testNonVisibleExtraFieldComponent(). Would appreciate thoughts! This separation should also make clear what needs to be tested for D7.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

hardikpandya’s picture

Status: Needs work » Needs review
StatusFileSize
new2.51 KB

Rerolled patch.

Status: Needs review » Needs work

The last submitted patch, 12: write_tests_for_rerolled-2165879-12.patch, failed testing.

erozqba’s picture

Status: Needs work » Needs review

All test passed!

jofitz’s picture

Issue tags: -Needs reroll

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

erozqba’s picture

Version: 8.3.x-dev » 8.4.x-dev
StatusFileSize
new2.28 KB

Rerolled patch to version 8.4.x

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work

Tagged for issue summary update 8 years ago and that still needs to happen it seems..

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Closed (outdated)