Skip to content

tests(theme): expand PHPUnit coverage of functions.php #100

Description

@JohnRDOrazio

Background

Following the Codecov rollout in #91 / #92, the wordpress-theme flag is currently at ~1% coverage. The theme PHPUnit <source> correctly includes both functions.php (~4900 lines) and includes/ (~80 lines), but only RelationshipHandlerTest.php exists — covering ~80 lines of includes/handlers/relationship.php. Everything in functions.php is uncovered.

This is the biggest single needle-mover for the project coverage number.

Suggested scope

Add Brain Monkey + Mockery tests for the REST endpoints currently registered in functions.php, using RelationshipHandlerTest.php as the pattern. In rough order of value (lines covered × user-facing impact):

  • /cdcf/v1/team-membercdcf_rest_create_team_member() (~180 lines). Cover happy path, the four council branches (board / ecclesial / technical / academic), the collab_post_id validation for academic_council, and the no-council "project-only member" branch.
  • /cdcf/v1/community-channel, /cdcf/v1/local-group, /cdcf/v1/academic-collaboration — all three follow the same translate-then-link-to-Community-page pattern. One helper test plus per-endpoint specifics.
  • /cdcf/v1/translate — OpenAI call should be mocked at the HTTP layer (Patchwork or wp_remote_post stub).
  • /cdcf/v1/maintenance — Redis flag set/clear, capability check, duration_seconds clamping.
  • /cdcf/v1/update-disposable-domains — GitHub fetch mocked, file-write side effect stubbed.
  • The Polylang admin-language seeding hook + the Team Members council submenu / pre_get_posts filter (added in feat(theme): group admin CPTs and polish admin UX #99).

Out of scope here

  • ACF field-group registration (configuration, not branching logic)
  • The acf/init REST-meta bridging hook (covered indirectly by any write-path test)
  • Admin sidebar menu structure (visual; testing it via Brain Monkey is high-effort, low-value)

Why now

The Codecov plumbing is in place but the theme number is misleading without more tests. Each REST endpoint test added moves the wordpress-theme flag by ~3-5% and exercises the most user-facing PHP in the repo.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions