Commit fa5708dd authored by Jeroen Tubex's avatar Jeroen Tubex Committed by Jeroen Tubex
Browse files

Issue #3292398 by JeroenT: Add test coverage

parent af201a8a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -13,18 +13,20 @@ function auto_entity_form_mode_entity_type_alter(array &$entity_types) {
  foreach ($entity_types as $entity_type_id => $entity_type) {
    // Get the form modes directly from config. We can't use the entity storage
    // since that would result in a recursive loop.
    $entity_form_mode_config_ids = $config_factory->listAll('core.entity_form_display.' . $entity_type_id);
    $entity_form_mode_config_ids = $config_factory->listAll('core.entity_form_mode.' . $entity_type_id);

    foreach ($entity_form_mode_config_ids as $entity_form_mode_config_id) {
      $entity_form_mode_config = $config_factory->get($entity_form_mode_config_id);
      $entity_form_mode_id = is_string($entity_form_mode_config->get('id')) ? (string) $entity_form_mode_config->get('id') : '';
      [, $entity_form_mode_form_class_id] = explode('.', $entity_form_mode_id);

      // Do nothing when the form class is already registered.
      if ($entity_types[$entity_type_id]->hasHandlerClass('form', $entity_form_mode_config->get('mode'))) {
      if ($entity_types[$entity_type_id]->hasHandlerClass('form', $entity_form_mode_form_class_id)) {
        continue;
      }

      $default_entity_form_class = $entity_types[$entity_type_id]->getFormClass('default');
      $entity_types[$entity_type_id]->setFormClass($entity_form_mode_config->get('mode'), $default_entity_form_class);
      $entity_types[$entity_type_id]->setFormClass($entity_form_mode_form_class_id, $default_entity_form_class);
    }
  }
}
+10 −0
Original line number Diff line number Diff line
name: Auto entity form mode Test
type: module
description: 'Support module for Auto entity form mode tests'
package: Testing
dependencies:
  - auto_entity_form_mode:auto_entity_form_mode
  - drupal:node
  - drupal:taxonomy
  - drupal:user
+9 −0
Original line number Diff line number Diff line
langcode: en
status: true
dependencies:
  module:
    - node
id: node.my_custom_node_form_display
label: My custom node form display
targetEntityType: node
cache: true
+9 −0
Original line number Diff line number Diff line
langcode: en
status: true
dependencies:
  module:
    - taxonomy
id: taxonomy_term.my_custom_taxonomy_term_form_display
label: My custom taxonomy term form display
targetEntityType: taxonomy_term
cache: true
+9 −0
Original line number Diff line number Diff line
langcode: en
status: true
dependencies:
  module:
    - user
id: user.my_custom_user_form_display
label: My custom user form display
targetEntityType: user
cache: true
Loading