Skip to content

Conversation

@priethor
Copy link
Contributor

@priethor priethor commented Dec 30, 2025

What

Part of #315.

Adds PHPUnit test coverage for 8 previously untested form type classes that handle field rendering in various WordPress contexts.

Why

Form classes are critical for displaying SCF fields in different WordPress admin screens including:

  • Attachment media library modal
  • Comment edit screens
  • Frontend forms
  • Gutenberg block editor
  • Nav menu item screens
  • Taxonomy term add/edit screens
  • User profile screens
  • Widget administration

How

Adding 144 tests across all form types:

File Class Tested Tests
test-form-attachment.php acf_form_attachment 14
test-form-comment.php acf_form_comment 12
test-form-front.php acf_form_front 19
test-form-gutenberg.php acf_form_gutenberg 24
test-form-nav-menu.php acf_form_nav_menu 17
test-form-taxonomy.php acf_form_taxonomy 15
test-form-user.php ACF_Form_User 21
test-form-widget.php acf_form_widget 15

Test coverage includes:

  • Class instantiation and constructor hook registration
  • Nonce verification for save operations
  • Render method behavior without matching field groups
  • Admin footer JavaScript output
  • Data providers for various parameter scenarios

Testing Instructions

Run the test suite:

./vendor/bin/phpunit --filter "Test_Form_Attachment|Test_Form_Comment|Test_Form_Front|Test_Form_Gutenberg|Test_Form_Nav_Menu|Test_Form_Taxonomy|Test_Form_User|Test_Form_Widget"

@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 25.13%. Comparing base (42c4ac8) to head (24f8777).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #333      +/-   ##
============================================
+ Coverage     23.67%   25.13%   +1.45%     
  Complexity     4410     4410              
============================================
  Files           291      291              
  Lines         36940    36916      -24     
============================================
+ Hits           8745     9278     +533     
+ Misses        28195    27638     -557     
Flag Coverage Δ
e2e 28.87% <ø> (ø)
javascript 6.53% <ø> (ø)
phpunit 24.98% <ø> (+2.00%) ⬆️

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 mentioned this pull request Dec 31, 2025
22 tasks
@priethor priethor force-pushed the 43ef-phase-2-pr-11-fo branch 2 times, most recently from 0ce46b6 to 941b2d0 Compare December 31, 2025 03:07
@priethor priethor added this to the 6.9.0 milestone Dec 31, 2025
@priethor priethor self-assigned this Dec 31, 2025
@priethor priethor force-pushed the 43ef-phase-2-pr-11-fo branch from 941b2d0 to 1ea7407 Compare December 31, 2025 03:13
Replace `assertTrue(true)` placeholder assertions with meaningful tests:

- test-form-attachment.php: Check that admin_footer action is NOT added on wrong screen
- test-form-nav-menu.php: Use acf_get_validation_errors() to verify validation behavior
- test-form-widget.php: Use acf_get_validation_errors() to verify validation behavior

These tests now verify actual behavior rather than just confirming code paths execute.
@priethor priethor merged commit e26e0e4 into trunk Dec 31, 2025
9 checks passed
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