Problem/Motivation

The subentity module lacks automated test coverage for several critical classes. ReferencedEntityAccessControlHandler has partial kernel test coverage but several paths are untested. EntityParentHandler::getStorageByEntityType() and the Drush generator (SubEntityGenerator) have no tests at all.

Proposed resolution

tests/src/Kernel/EntityParentHandlerTest.php

Kernel tests covering EntityParentHandler::getStorageByEntityType():

  • Returns empty array when no referencing field exists
  • Groups results by parent entity type
  • Handles multiple referencing fields on the same parent type
  • Excludes fields targeting other entity types

tests/src/Unit/SubEntityGeneratorTest.php

Unit tests covering the Drush generator:

  • All templates referenced in generate() exist on disk
  • routing.yml.twig uses the module-specific administer subentities permission and not the generic administer site configuration

tests/src/Kernel/ReferencedEntityAccessControlHandlerTest.php

Additional cases for the existing test class:

  • checkAccess() when no parent references the subentity → should return neutral()
  • checkAccess() when the parent exists but denies the operation → should return neutral()
  • checkCreateAccess() when a referencing field exists and the parent allows creation → should return allowed()

Remaining tasks

  • Create tests/src/Kernel/EntityParentHandlerTest.php
  • Create tests/src/Unit/SubEntityGeneratorTest.php
  • Update tests/src/Kernel/ReferencedEntityAccessControlHandlerTest.php
  • Verify all tests pass via phpunit --group subentity

Issue fork subentity-3599843

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

macsim created an issue. See original summary.

macsim’s picture

Issue summary: View changes
macsim’s picture

Issue summary: View changes

macsim’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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