Skip to content

Conversation

@priethor
Copy link
Contributor

@priethor priethor commented Dec 30, 2025

What

Part of #315.

Adds PHPUnit test coverage for hook, WordPress wrapper, and bidirectional functions.

Why

These functions handle critical WordPress hook management (filter/action variations, deprecated hook bridging), object type resolution, and bidirectional field relationships.

How

Adding 109 tests covering:

  • Filter and action variations registration and application
  • Deprecated hook registration and backward compatibility bridging
  • Object type resolution for post, term, user, comment, block, option, menu
  • Post ID decoding for various formats (numeric, user_X, term_X, etc.)
  • REST base resolution for post types and taxonomies
  • Object ID extraction from WP_Post, WP_User, WP_Term, WP_Comment
  • Bidirectional relationship target types and choice building
  • Bidirectional value update recursion prevention
  • Field settings rendering for bidirectional fields

Testing Instructions

Run the test suite: ./vendor/bin/phpunit --filter "Test_ACF_Hook_Functions|Test_ACF_WP_Functions|Test_ACF_Bidirectional_Functions"

@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props priethor.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.32%. Comparing base (f0036e7) to head (8551a66).
⚠️ Report is 5 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #325      +/-   ##
============================================
+ Coverage     16.68%   20.32%   +3.64%     
  Complexity     4410     4410              
============================================
  Files           291      291              
  Lines         36995    36940      -55     
============================================
+ Hits           6173     7509    +1336     
+ Misses        30822    29431    -1391     
Flag Coverage Δ
e2e 28.87% <ø> (ø)
javascript 2.50% <ø> (ø)
phpunit 19.87% <ø> (+4.99%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@priethor priethor force-pushed the 17a1-phase-1-pr-8-hoo branch from 961b6a5 to 44c1a0d Compare December 30, 2025 12:18
@priethor priethor changed the title Add PHPUnit tests for hook, WP, and bidirectional functions Tests: Add PHPUnit tests for hook, WP, and bidirectional functions Dec 30, 2025
@priethor priethor force-pushed the 17a1-phase-1-pr-8-hoo branch from 44c1a0d to 3365f0f Compare December 30, 2025 12:21
@priethor priethor mentioned this pull request Dec 30, 2025
22 tasks
Adds 109 PHPUnit tests covering three function files from includes/:

- acf-hook-functions.php (28 tests): Filter/action variations registration
  and application, deprecated hook handling and backward compatibility
- acf-wp-functions.php (53 tests): Object type resolution, post ID decoding,
  REST base resolution, and object ID extraction from various WordPress types
- acf-bidirectional-functions.php (28 tests): Bidirectional relationship
  target types, choice building, value updates, and field settings rendering

All tests use WorDBless for lightweight WordPress environment simulation and
include data providers for comprehensive edge case coverage.

Part of Phase 1 testing strategy implementation.
@priethor priethor force-pushed the 17a1-phase-1-pr-8-hoo branch from 3365f0f to 8551a66 Compare December 30, 2025 12:34
@priethor priethor merged commit 53a23f4 into trunk Dec 30, 2025
9 checks passed
@priethor priethor deleted the 17a1-phase-1-pr-8-hoo branch December 30, 2025 12:40
@priethor priethor added this to the 6.8.0 milestone Dec 30, 2025
@priethor priethor self-assigned this Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants