Tests: Add PHPUnit tests for helper and utility functions#327
Tests: Add PHPUnit tests for helper and utility functions#327
Conversation
Add 159 tests covering acf-helper-functions.php (136 tests) and acf-utility-functions.php (23 tests) with 222 assertions total. Helper function tests cover: - acf_is_empty/acf_not_empty with numeric edge cases - acf_uniqid counter and prefix behavior - acf_merge_attributes class/style concatenation - Filter enable/disable/get/set operations - acf_idval/acf_maybe_idval ID extraction - acf_format_numerics/acf_numval type conversion - acf_idify/acf_slugify/acf_punctify string formatting - acf_strlen with line breaks and multibyte chars - acf_sanitize_request_args type handling and XSS prevention - acf_sanitize_files_array single and multiple file handling - acf_maybe_unserialize with class blocking security Utility function tests cover: - acf_new_instance/acf_get_instance singleton pattern - acf_register_store/acf_get_store data management - acf_get_path/acf_get_url path resolution - acf_include path handling behavior All tests use data providers for comprehensive edge case coverage and include documentation for non-obvious behavior.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #327 +/- ##
============================================
+ Coverage 13.55% 17.22% +3.66%
- Complexity 4404 4410 +6
============================================
Files 291 291
Lines 36984 36995 +11
============================================
+ Hits 5014 6372 +1358
+ Misses 31970 30623 -1347
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What
Part of #315.
Adds PHPUnit test coverage for SCF helper and utility functions in
acf-helper-functions.phpandacf-utility-functions.php.Why
Helper functions provide foundational utilities used throughout SCF (empty checks, sanitization, filters, string formatting). Utility functions manage core patterns like singletons, stores, and path resolution. Tests ensure these building blocks work correctly.
How
Adding 159 tests covering:
acf_is_empty,acf_not_empty)Testing Instructions
Run the test suite:
./vendor/bin/phpunit --filter "Test_ACF_Helper_Functions|Test_ACF_Utility_Functions"