Skip to content

PHPUnit suite refactor + CI overhaul#1660

Merged
jakejackson1 merged 1 commit into
developmentfrom
phpunit-refactor-squashed
Jun 4, 2026
Merged

PHPUnit suite refactor + CI overhaul#1660
jakejackson1 merged 1 commit into
developmentfrom
phpunit-refactor-squashed

Conversation

@jakejackson1

@jakejackson1 jakejackson1 commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR refactors the PHPUnit suite and rebuilds the CI workflow around it.

The suite now mirrors src/ one-to-one with Test_*.php naming, so a failing test points straight at the class it covers. The old suite-scoped $GLOBALS['GFPDF_Test'] fixtures are gone: each test class declares the forms and entries it needs via static::load_fixtures(), which keeps tests isolated and lets bootstrap stop eagerly building fixtures a given test may never touch. Phase 4 added characterization coverage for the largest Controllers, Models, Helpers, and Views, bringing total coverage to 81.57%.

On the CI side, the separate PHPUnit, Playwright, and JS workflows are consolidated into one tests.yml. PR coverage renders inline as a comment, Docker base images are cached to cut cold-start time, and a flaky test is retried once before it fails the run. PRs run a tightened PHP matrix (floor plus ceiling) for fast feedback; the weekly cron and the new run-tests-php-all label run the full 7.4 to 8.5 matrix, and the multisite suite runs on the floor and ceiling cells.

Try it

git fetch origin phpunit-refactor-squashed && git checkout phpunit-refactor-squashed
yarn wp-env:integration start
yarn test:php
yarn test:php:multisite

Test plan

  • PR PHPUnit matrix passes (PHP 7.4 + 8.5, plus the 8.3 coverage cell)
  • Multisite suite passes on the floor (7.4) and ceiling (8.5) cells
  • Adding the run-tests-php-all label expands the PR run to the full 7.4–8.5 matrix
  • Coverage comment renders with merged single-site + multisite Clover, at or above the 81.45% baseline
  • Banned fixture-pattern grep gate ($GLOBALS['GFPDF_Test'], GFAPI::add_form, GFAPI::add_entry) reports clean
  • Playwright E2E (4 shards) passes
  • JS unit tests pass in the consolidated tests.yml
  • No ::warning::retry: annotations in the workflow log (a survivor would mean a real flake got past Phase 4)
More info

Test architecture

  • Mirror src/ 1:1 with Test_*.php naming; relocated the 32 root-level test-*.php files into per-class files under tests/phpunit/integration/.
  • Phase 4 characterization coverage for Controllers, Models, Helpers (Fields/Fonts), and Views. Final coverage 81.57% (gate 81.45%).
  • New AjaxTestCase parallel to WP_Ajax_UnitTestCase; shared HasGfpdfFixtures trait exposes form() / entry() / entries() accessors to both base classes.
  • Trivial exception classes and pure template wrappers skipped per the documented "test if non-trivial" rule.
  • tests/phpunit/README.md documents the suite layout, the fixture system, and the available fixture keys.

Fixtures-to-factory migration (follow-up epic, same PR)

  • Removed the suite-scoped $GLOBALS['GFPDF_Test'] global across 62 test files; bootstrap's create_stubs() deleted along with the orphan gravityform-2.json fixture.
  • Replaced with per-class static::load_fixtures() declarations populating a protected $fixture_caches map on HasGfpdfFixtures.
  • Two factory import paths preserved: import_and_get (array-wrapped GF-export JSON) and import_fixture_and_get (raw-object JSON used by load_fixtures).
  • CI grep gate in .github/workflows/tests.yml blocks regression to $GLOBALS['GFPDF_Test'], GFAPI::add_form, GFAPI::add_entry in test files.
  • Suite is 1503 tests / ~4750 assertions / 14 skipped — ~40s single-site, ~38s multisite. Runtime improved versus the +10% budget because bootstrap no longer eagerly creates 7 forms + 5 entry sets at suite start.

Suite speed + stability

  • Killed the sleep(1) flake in Test_Url_Signer; lifted gf_factory writes to class scope.
  • Blocked external HTTP and stripped WP update probes from AJAX setup.
  • Unique zip names per Test_Templates stage to kill cross-test flake.
  • Closed leak vectors and shaved wall-clock across the suite; post-Phase-4 flake budget is zero.
  • Dropped vendored Polls/Quiz/Survey plugins, replaced with a minimal class-stub surface for PHPUnit.

CI infrastructure

  • Consolidated PHPUnit + Playwright + JS workflows into a single tests.yml; extended the deps update workflow.
  • PR coverage renders inline via lucassabreu/comment-coverage-clover (Codecov + token removed). tools/phpunit/coverage-merge.php unions single-site + multisite Clover before the comment step.
  • tools/phpunit/retry.sh re-runs only the failing Class::method names (parsed from JUnit XML) once on flake; retries surface as ::warning::retry: annotations. --coverage-clover is stripped from retry args so the full-suite Clover isn't overwritten by a single-test subset.
  • wp-env Docker base images (wordpress:php<v>, wordpress:cli-php<v>, mariadb:lts) cached via docker save / docker load, removing ~60-90s of cold-pull per matrix cell / Playwright shard. docker/setup-buildx-action@v3 removed from PHPUnit — wp-env never used it.
  • PHP floor wired to 7.4 in composer.json to match what Gravity Forms (required dep) already needs; setup-php now matches ${{ matrix.php }} instead of being hardcoded to 7.4.
  • Docker Hub pulls routed through Google's mirror to dodge rate limits.
  • run-tests-php-all PR label opts into the full PHP-version matrix on demand (cron still runs it weekly). Multisite runs on declarative floor (7.4) + ceiling (8.5) cells via matrix include flags rather than the 8.3 coverage cell.

Known follow-ups (separate epics)

  • Phase 6 Model_PDF refactor.
  • 6 pre-existing order-coupled failures surface under --order-by=random (Test_Templates filesystem state, Test_Uninstaller / Test_Actions notices, Test_Rest_Pdf_Preview) — hidden by deterministic discovery order in the legacy suite; not introduced by this work.

Plans: .claude/plans/2026-05-25-phpunit-tests-refactor.md, .claude/plans/2026-05-26-fixtures-to-factory-migration.md.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown

Coverage report for commit: 460ad8f
File: ./tmp/jest-coverage/clover.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ █░░░░░░░░░░░░░░░░░░░░░░ │  1.6%
  80% │ ███░░░░░░░░░░░░░░░░░░░░ │  8.2%
  90% │ ████████░░░░░░░░░░░░░░░ │ 21.3%
 100% │ ███████████████████████ │ 68.9%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 92.96% | Methods: 88.24% | Branches: 81.37%
FilesLinesMethodsBranches
src/assets/js/react/actions
   coreFonts.js100.00%100.00%100.00%
   fontManager.js100.00%100.00%100.00%
   templates.js100.00%100.00%100.00%
src/assets/js/react/components/Alert
   Alert.js100.00%100.00%100.00%
src/assets/js/react/components/CoreFonts
   CoreFontContainer.js100.00%100.00%91.43%
   CoreFontCounter.js100.00%100.00%100.00%
   CoreFontListResults.js100.00%100.00%85.71%
   CoreFontListSpacer.js100.00%100.00%100.00%
src/assets/js/react/components
   Empty.js100.00%100.00%100.00%
   ShowMessage.js79.31%80.00%64.29%
   Spinner.js100.00%100.00%100.00%
src/assets/js/react/components/FontManager
   AddFont.js100.00%100.00%100.00%
   AddUpdateFontFooter.js85.37%50.00%88.89%
   AdvancedButton.js100.00%100.00%100.00%
   FontList.js100.00%50.00%65.22%
   FontListAlertMessage.js100.00%100.00%100.00%
   FontListHeader.js100.00%100.00%100.00%
   FontListIcon.js100.00%100.00%100.00%
   FontListItems.js85.39%64.00%68.66%
   FontListSkeleton.js100.00%100.00%100.00%
   FontManager.js77.78%57.14%50.00%
   FontManagerBody.js94.20%96.43%90.29%
   FontManagerHeader.js100.00%100.00%100.00%
   FontVariant.js90.00%60.00%70.00%
   FontVariantLabel.js100.00%100.00%100.00%
   InitialAddUpdateState.js100.00%100.00%100.00%
   SearchBox.js90.00%66.67%69.23%
   TemplateTooltip.js100.00%75.00%100.00%
   UpdateFont.js75.00%50.00%75.00%
src/assets/js/react/components/Modal
   CloseDialog.js93.33%66.67%70.59%
src/assets/js/react/components/Template
   TemplateActivateButton.js100.00%100.00%100.00%
   TemplateButton.js85.71%66.67%100.00%
   TemplateContainer.js71.43%66.67%25.00%
   TemplateDeleteButton.js100.00%100.00%70.00%
   TemplateFooterActions.js100.00%100.00%100.00%
   TemplateHeaderNavigation.js82.35%85.71%70.00%
   TemplateHeaderTitle.js100.00%100.00%100.00%
   TemplateList.js100.00%100.00%60.00%
   TemplateListItem.js100.00%100.00%92.86%
   TemplateListItemComponents.js100.00%100.00%100.00%
   TemplateScreenshot.js100.00%100.00%100.00%
   TemplateScreenshots.js100.00%100.00%50.00%
   TemplateSearch.js93.75%88.89%50.00%
   TemplateSingle.js100.00%100.00%100.00%
   TemplateSingleComponents.js100.00%100.00%75.00%
   TemplateUploader.js98.04%100.00%86.67%
src/assets/js/react/reducers
   coreFontReducer.js95.65%100.00%88.00%
   fontManagerReducer.js87.21%75.00%75.00%
   index.js100.00%100.00%100.00%
   templateReducer.js100.00%100.00%100.00%
src/assets/js/react/sagas
   coreFonts.js91.67%100.00%75.00%
   fontManager.js86.96%90.00%83.33%
   index.js100.00%100.00%100.00%
   templates.js83.33%100.00%100.00%
src/assets/js/react/selectors
   getTemplates.js91.11%100.00%83.33%
src/assets/js/react/utilities/FontManager
   adjustFontListHeight.js100.00%100.00%100.00%
   associatedFontManagerSelectBox.js94.44%100.00%66.67%
   fontManagerReducer.js100.00%100.00%100.00%
   getTabLocation.js100.00%100.00%100.00%
   toggleUpdateFont.js100.00%100.00%100.00%
src/assets/js/react/utilities
   withRouterHooks.js100.00%100.00%100.00%

🤖 comment via lucassabreu/comment-coverage-clover

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown

Coverage report for commit: 460ad8f
File: tmp/coverage/report-xml/merged.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ██████████░░░░░░░░░░░░░ │ 11.5%
  10% │ █░░░░░░░░░░░░░░░░░░░░░░ │  1.0%
  20% │ █░░░░░░░░░░░░░░░░░░░░░░ │  0.5%
  30% │ ██░░░░░░░░░░░░░░░░░░░░░ │  1.4%
  40% │ █░░░░░░░░░░░░░░░░░░░░░░ │  0.5%
  50% │ ███████░░░░░░░░░░░░░░░░ │  8.2%
  60% │ ██░░░░░░░░░░░░░░░░░░░░░ │  1.4%
  70% │ ███████░░░░░░░░░░░░░░░░ │  7.7%
  80% │ ████████████████░░░░░░░ │ 19.7%
  90% │ ███████████████████████ │ 28.8%
 100% │ ████████████████░░░░░░░ │ 19.2%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 82.18% | Methods: 88.63%
FilesLinesMethodsBranches
/var/www/html/wp-content/plugins/gravity-pdf
   api.php96.24%100.00%100.00%
   gravity-pdf-updater.php27.50%100.00%100.00%
   pdf.php60.34%87.50%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Controller
   Controller_Actions.php100.00%100.00%100.00%
   Controller_Activation.php95.45%100.00%100.00%
   Controller_Custom_Fonts.php88.52%100.00%100.00%
   Controller_Debug.php100.00%100.00%100.00%
   Controller_Export_Entries.php96.67%100.00%100.00%
   Controller_Form_Settings.php86.05%90.00%100.00%
   Controller_Install.php100.00%100.00%100.00%
   Controller_Mergetags.php100.00%100.00%100.00%
   Controller_PDF.php82.05%100.00%100.00%
   Controller_Pdf_Queue.php83.72%77.78%100.00%
   Controller_Save_Core_Fonts.php66.67%100.00%100.00%
   Controller_Settings.php80.23%100.00%100.00%
   Controller_Shortcodes.php100.00%100.00%100.00%
   Controller_System_Report.php100.00%100.00%100.00%
   Controller_Templates.php100.00%100.00%100.00%
   Controller_Uninstaller.php83.33%77.78%100.00%
   Controller_Upgrade_Routines.php93.33%100.00%100.00%
   Controller_Webhooks.php100.00%100.00%100.00%
   Controller_Zapier.php100.00%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Exceptions
   GravityPdfDatabaseUpdateException.php50.00%100.00%100.00%
   GravityPdfDomainException.php50.00%100.00%100.00%
   GravityPdfException.php50.00%100.00%100.00%
   GravityPdfFontNotFoundException.php50.00%100.00%100.00%
   GravityPdfIdException.php50.00%100.00%100.00%
   GravityPdfModelNotUpdatedException.php50.00%100.00%100.00%
   GravityPdfRuntimeException.php50.00%100.00%100.00%
   GravityPdfShortcodeEntryIdException.php50.00%100.00%100.00%
   GravityPdfShortcodePdfConditionalLogicFailedException.php50.00%100.00%100.00%
   GravityPdfShortcodePdfConfigNotFoundException.php50.00%100.00%100.00%
   GravityPdfShortcodePdfInactiveException.php50.00%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Fields
   Field_Address.php92.16%100.00%100.00%
   Field_Chainedselect.php66.67%75.00%100.00%
   Field_Checkbox.php94.34%100.00%100.00%
   Field_Consent.php89.47%100.00%100.00%
   Field_Coupon.php--100.00%
   Field_Creditcard.php83.33%100.00%100.00%
   Field_Date.php83.33%100.00%100.00%
   Field_Default.php83.33%100.00%100.00%
   Field_Discount.php44.00%75.00%100.00%
   Field_Email.php83.33%100.00%100.00%
   Field_Fg_Ls_Consent.php92.86%100.00%100.00%
   Field_Fg_Ls_Signature.php73.08%66.67%100.00%
   Field_Fileupload.php94.23%100.00%100.00%
   Field_Form.php89.09%100.00%100.00%
   Field_Hidden.php81.82%100.00%100.00%
   Field_Html.php89.47%100.00%100.00%
   Field_Image_Choice.php86.67%100.00%100.00%
   Field_Likert.php97.22%100.00%100.00%
   Field_List.php92.41%100.00%100.00%
   Field_Multi_Choice.php50.00%100.00%100.00%
   Field_Multiselect.php92.59%100.00%100.00%
   Field_Name.php84.62%100.00%100.00%
   Field_Number.php83.33%100.00%100.00%
   Field_Option.php57.69%50.00%100.00%
   Field_Page.php83.33%100.00%100.00%
   Field_Phone.php81.82%100.00%100.00%
   Field_Poll.php93.75%100.00%100.00%
   Field_Post_Category.php85.00%100.00%100.00%
   Field_Post_Content.php82.35%100.00%100.00%
   Field_Post_Custom_Field.php50.00%100.00%100.00%
   Field_Post_Excerpt.php81.82%100.00%100.00%
   Field_Post_Image.php94.00%100.00%100.00%
   Field_Post_Tags.php90.91%100.00%100.00%
   Field_Post_Title.php81.82%100.00%100.00%
   Field_Product.php88.46%100.00%100.00%
   Field_Products.php85.41%100.00%100.00%
   Field_Quantity.php84.62%100.00%100.00%
   Field_Quiz.php89.74%100.00%100.00%
   Field_Radio.php95.35%100.00%100.00%
   Field_Rank.php95.24%100.00%100.00%
   Field_Rating.php95.24%100.00%100.00%
   Field_Repeater.php97.37%100.00%100.00%
   Field_Section.php90.74%100.00%100.00%
   Field_Select.php94.12%100.00%100.00%
   Field_Shipping.php75.00%66.67%100.00%
   Field_Signature.php67.39%100.00%100.00%
   Field_Slim.php82.35%100.00%100.00%
   Field_Slim_Post.php91.30%100.00%100.00%
   Field_Subtotal.php65.38%75.00%100.00%
   Field_Survey.php95.00%100.00%100.00%
   Field_Tax.php32.00%50.00%100.00%
   Field_Text.php81.82%100.00%100.00%
   Field_Textarea.php90.63%100.00%100.00%
   Field_Time.php81.82%100.00%100.00%
   Field_Tos.php92.59%100.00%100.00%
   Field_Total.php68.00%66.67%100.00%
   Field_V3_List.php92.86%100.00%100.00%
   Field_V3_Products.php73.68%100.00%100.00%
   Field_V3_Section.php77.78%100.00%100.00%
   Field_Website.php85.71%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Fonts
   FlushCache.php80.00%100.00%100.00%
   LocalFile.php90.00%100.00%100.00%
   LocalFilesystem.php66.67%100.00%100.00%
   SupportsOtl.php88.89%100.00%100.00%
   TtfFontValidation.php72.73%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper
   Helper_Abstract_Addon.php92.14%100.00%100.00%
   Helper_Abstract_Config_Settings.php75.00%100.00%100.00%
   Helper_Abstract_Controller.php-100.00%100.00%
   Helper_Abstract_Field_Products.php89.47%66.67%100.00%
   Helper_Abstract_Fields.php93.59%93.75%100.00%
   Helper_Abstract_Fields_Input_Type.php84.00%100.00%100.00%
   Helper_Abstract_Form.php--100.00%
   Helper_Abstract_Model.php100.00%100.00%100.00%
   Helper_Abstract_Options.php74.73%75.00%100.00%
   Helper_Abstract_Pdf_Shortcode.php89.52%91.67%100.00%
   Helper_Abstract_View.php95.83%100.00%100.00%
   Helper_Data.php96.57%100.00%100.00%
   Helper_Field_Container.php92.31%100.00%100.00%
   Helper_Field_Container_Gf25.php82.22%100.00%100.00%
   Helper_Field_Container_Void.php16.67%-100.00%
   Helper_Form.php70.97%64.29%100.00%
   Helper_Interface_Actions.php-100.00%100.00%
   Helper_Interface_Config.php50.00%100.00%100.00%
   Helper_Interface_Config_Settings.php50.00%100.00%100.00%
   Helper_Interface_Extension_Settings.php-100.00%100.00%
   Helper_Interface_Extension_Uninstaller.php-100.00%100.00%
   Helper_Interface_Field_Pdf_Config.php50.00%100.00%100.00%
   Helper_Interface_Filters.php-100.00%100.00%
   Helper_Interface_Setup_TearDown.php-100.00%100.00%
   Helper_Interface_Url_Signer.php-100.00%100.00%
   Helper_Logger.php-100.00%100.00%
   Helper_Misc.php73.12%90.63%100.00%
   Helper_Mpdf.php50.00%100.00%100.00%
   Helper_Notices.php79.31%78.57%100.00%
   Helper_Options_Fields.php96.41%94.12%100.00%
   Helper_PDF.php89.66%94.29%100.00%
   Helper_PDF_List_Table.php84.50%92.31%100.00%
   Helper_Pdf_Queue.php84.31%100.00%100.00%
   Helper_QueryPath.php80.00%100.00%100.00%
   Helper_Sha256_Url_Signer.php87.50%100.00%100.00%
   Helper_Singleton.php90.00%100.00%100.00%
   Helper_Templates.php96.43%100.00%100.00%
   Helper_Trait_Logger.php--100.00%
   Helper_Url_Signer.php82.18%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Licensing
   EDD_SL_Plugin_Updater.php96.64%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Log
   Logger.php70.10%100.00%100.00%
   MonoLoggerPsrLog2And3.php--100.00%
   Redact_Processor.php100.00%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Mpdf
   Cache.php66.67%100.00%100.00%
Table truncated to fit comment

🤖 comment via lucassabreu/comment-coverage-clover

@jakejackson1 jakejackson1 mentioned this pull request May 27, 2026
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

Coverage report for commit: 2228837
File: ./tmp/jest-coverage/clover.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ █░░░░░░░░░░░░░░░░░░░░░░ │  1.6%
  80% │ ███░░░░░░░░░░░░░░░░░░░░ │  8.2%
  90% │ ████████░░░░░░░░░░░░░░░ │ 21.3%
 100% │ ███████████████████████ │ 68.9%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 92.96% | Methods: 88.24% | Branches: 81.37%
FilesLinesMethodsBranches
src/assets/js/react/actions
   coreFonts.js100.00%100.00%100.00%
   fontManager.js100.00%100.00%100.00%
   templates.js100.00%100.00%100.00%
src/assets/js/react/components/Alert
   Alert.js100.00%100.00%100.00%
src/assets/js/react/components/CoreFonts
   CoreFontContainer.js100.00%100.00%91.43%
   CoreFontCounter.js100.00%100.00%100.00%
   CoreFontListResults.js100.00%100.00%85.71%
   CoreFontListSpacer.js100.00%100.00%100.00%
src/assets/js/react/components
   Empty.js100.00%100.00%100.00%
   ShowMessage.js79.31%80.00%64.29%
   Spinner.js100.00%100.00%100.00%
src/assets/js/react/components/FontManager
   AddFont.js100.00%100.00%100.00%
   AddUpdateFontFooter.js85.37%50.00%88.89%
   AdvancedButton.js100.00%100.00%100.00%
   FontList.js100.00%50.00%65.22%
   FontListAlertMessage.js100.00%100.00%100.00%
   FontListHeader.js100.00%100.00%100.00%
   FontListIcon.js100.00%100.00%100.00%
   FontListItems.js85.39%64.00%68.66%
   FontListSkeleton.js100.00%100.00%100.00%
   FontManager.js77.78%57.14%50.00%
   FontManagerBody.js94.20%96.43%90.29%
   FontManagerHeader.js100.00%100.00%100.00%
   FontVariant.js90.00%60.00%70.00%
   FontVariantLabel.js100.00%100.00%100.00%
   InitialAddUpdateState.js100.00%100.00%100.00%
   SearchBox.js90.00%66.67%69.23%
   TemplateTooltip.js100.00%75.00%100.00%
   UpdateFont.js75.00%50.00%75.00%
src/assets/js/react/components/Modal
   CloseDialog.js93.33%66.67%70.59%
src/assets/js/react/components/Template
   TemplateActivateButton.js100.00%100.00%100.00%
   TemplateButton.js85.71%66.67%100.00%
   TemplateContainer.js71.43%66.67%25.00%
   TemplateDeleteButton.js100.00%100.00%70.00%
   TemplateFooterActions.js100.00%100.00%100.00%
   TemplateHeaderNavigation.js82.35%85.71%70.00%
   TemplateHeaderTitle.js100.00%100.00%100.00%
   TemplateList.js100.00%100.00%60.00%
   TemplateListItem.js100.00%100.00%92.86%
   TemplateListItemComponents.js100.00%100.00%100.00%
   TemplateScreenshot.js100.00%100.00%100.00%
   TemplateScreenshots.js100.00%100.00%50.00%
   TemplateSearch.js93.75%88.89%50.00%
   TemplateSingle.js100.00%100.00%100.00%
   TemplateSingleComponents.js100.00%100.00%75.00%
   TemplateUploader.js98.04%100.00%86.67%
src/assets/js/react/reducers
   coreFontReducer.js95.65%100.00%88.00%
   fontManagerReducer.js87.21%75.00%75.00%
   index.js100.00%100.00%100.00%
   templateReducer.js100.00%100.00%100.00%
src/assets/js/react/sagas
   coreFonts.js91.67%100.00%75.00%
   fontManager.js86.96%90.00%83.33%
   index.js100.00%100.00%100.00%
   templates.js83.33%100.00%100.00%
src/assets/js/react/selectors
   getTemplates.js91.11%100.00%83.33%
src/assets/js/react/utilities/FontManager
   adjustFontListHeight.js100.00%100.00%100.00%
   associatedFontManagerSelectBox.js94.44%100.00%66.67%
   fontManagerReducer.js100.00%100.00%100.00%
   getTabLocation.js100.00%100.00%100.00%
   toggleUpdateFont.js100.00%100.00%100.00%
src/assets/js/react/utilities
   withRouterHooks.js100.00%100.00%100.00%

🤖 Jest coverage report

@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

Coverage report for commit: 2228837
File: tmp/coverage/report-xml/merged.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ██████████░░░░░░░░░░░░░ │ 11.5%
  10% │ █░░░░░░░░░░░░░░░░░░░░░░ │  1.0%
  20% │ █░░░░░░░░░░░░░░░░░░░░░░ │  0.5%
  30% │ ██░░░░░░░░░░░░░░░░░░░░░ │  1.4%
  40% │ █░░░░░░░░░░░░░░░░░░░░░░ │  0.5%
  50% │ ███████░░░░░░░░░░░░░░░░ │  8.2%
  60% │ ██░░░░░░░░░░░░░░░░░░░░░ │  1.4%
  70% │ ███████░░░░░░░░░░░░░░░░ │  7.7%
  80% │ ████████████████░░░░░░░ │ 19.7%
  90% │ ███████████████████████ │ 28.8%
 100% │ ████████████████░░░░░░░ │ 19.2%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 82.18% | Methods: 88.63%
FilesLinesMethodsBranches
/var/www/html/wp-content/plugins/gravity-pdf
   api.php96.24%100.00%100.00%
   gravity-pdf-updater.php27.50%100.00%100.00%
   pdf.php60.34%87.50%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Controller
   Controller_Actions.php100.00%100.00%100.00%
   Controller_Activation.php95.45%100.00%100.00%
   Controller_Custom_Fonts.php88.52%100.00%100.00%
   Controller_Debug.php100.00%100.00%100.00%
   Controller_Export_Entries.php96.67%100.00%100.00%
   Controller_Form_Settings.php86.05%90.00%100.00%
   Controller_Install.php100.00%100.00%100.00%
   Controller_Mergetags.php100.00%100.00%100.00%
   Controller_PDF.php82.05%100.00%100.00%
   Controller_Pdf_Queue.php83.72%77.78%100.00%
   Controller_Save_Core_Fonts.php66.67%100.00%100.00%
   Controller_Settings.php80.23%100.00%100.00%
   Controller_Shortcodes.php100.00%100.00%100.00%
   Controller_System_Report.php100.00%100.00%100.00%
   Controller_Templates.php100.00%100.00%100.00%
   Controller_Uninstaller.php83.33%77.78%100.00%
   Controller_Upgrade_Routines.php93.33%100.00%100.00%
   Controller_Webhooks.php100.00%100.00%100.00%
   Controller_Zapier.php100.00%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Exceptions
   GravityPdfDatabaseUpdateException.php50.00%100.00%100.00%
   GravityPdfDomainException.php50.00%100.00%100.00%
   GravityPdfException.php50.00%100.00%100.00%
   GravityPdfFontNotFoundException.php50.00%100.00%100.00%
   GravityPdfIdException.php50.00%100.00%100.00%
   GravityPdfModelNotUpdatedException.php50.00%100.00%100.00%
   GravityPdfRuntimeException.php50.00%100.00%100.00%
   GravityPdfShortcodeEntryIdException.php50.00%100.00%100.00%
   GravityPdfShortcodePdfConditionalLogicFailedException.php50.00%100.00%100.00%
   GravityPdfShortcodePdfConfigNotFoundException.php50.00%100.00%100.00%
   GravityPdfShortcodePdfInactiveException.php50.00%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Fields
   Field_Address.php92.16%100.00%100.00%
   Field_Chainedselect.php66.67%75.00%100.00%
   Field_Checkbox.php94.34%100.00%100.00%
   Field_Consent.php89.47%100.00%100.00%
   Field_Coupon.php--100.00%
   Field_Creditcard.php83.33%100.00%100.00%
   Field_Date.php83.33%100.00%100.00%
   Field_Default.php83.33%100.00%100.00%
   Field_Discount.php44.00%75.00%100.00%
   Field_Email.php83.33%100.00%100.00%
   Field_Fg_Ls_Consent.php92.86%100.00%100.00%
   Field_Fg_Ls_Signature.php73.08%66.67%100.00%
   Field_Fileupload.php94.23%100.00%100.00%
   Field_Form.php89.09%100.00%100.00%
   Field_Hidden.php81.82%100.00%100.00%
   Field_Html.php89.47%100.00%100.00%
   Field_Image_Choice.php86.67%100.00%100.00%
   Field_Likert.php97.22%100.00%100.00%
   Field_List.php92.41%100.00%100.00%
   Field_Multi_Choice.php50.00%100.00%100.00%
   Field_Multiselect.php92.59%100.00%100.00%
   Field_Name.php84.62%100.00%100.00%
   Field_Number.php83.33%100.00%100.00%
   Field_Option.php57.69%50.00%100.00%
   Field_Page.php83.33%100.00%100.00%
   Field_Phone.php81.82%100.00%100.00%
   Field_Poll.php93.75%100.00%100.00%
   Field_Post_Category.php85.00%100.00%100.00%
   Field_Post_Content.php82.35%100.00%100.00%
   Field_Post_Custom_Field.php50.00%100.00%100.00%
   Field_Post_Excerpt.php81.82%100.00%100.00%
   Field_Post_Image.php94.00%100.00%100.00%
   Field_Post_Tags.php90.91%100.00%100.00%
   Field_Post_Title.php81.82%100.00%100.00%
   Field_Product.php88.46%100.00%100.00%
   Field_Products.php85.41%100.00%100.00%
   Field_Quantity.php84.62%100.00%100.00%
   Field_Quiz.php89.74%100.00%100.00%
   Field_Radio.php95.35%100.00%100.00%
   Field_Rank.php95.24%100.00%100.00%
   Field_Rating.php95.24%100.00%100.00%
   Field_Repeater.php97.37%100.00%100.00%
   Field_Section.php90.74%100.00%100.00%
   Field_Select.php94.12%100.00%100.00%
   Field_Shipping.php75.00%66.67%100.00%
   Field_Signature.php67.39%100.00%100.00%
   Field_Slim.php82.35%100.00%100.00%
   Field_Slim_Post.php91.30%100.00%100.00%
   Field_Subtotal.php65.38%75.00%100.00%
   Field_Survey.php95.00%100.00%100.00%
   Field_Tax.php32.00%50.00%100.00%
   Field_Text.php81.82%100.00%100.00%
   Field_Textarea.php90.63%100.00%100.00%
   Field_Time.php81.82%100.00%100.00%
   Field_Tos.php92.59%100.00%100.00%
   Field_Total.php68.00%66.67%100.00%
   Field_V3_List.php92.86%100.00%100.00%
   Field_V3_Products.php73.68%100.00%100.00%
   Field_V3_Section.php77.78%100.00%100.00%
   Field_Website.php85.71%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Fonts
   FlushCache.php80.00%100.00%100.00%
   LocalFile.php90.00%100.00%100.00%
   LocalFilesystem.php66.67%100.00%100.00%
   SupportsOtl.php88.89%100.00%100.00%
   TtfFontValidation.php72.73%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper
   Helper_Abstract_Addon.php92.14%100.00%100.00%
   Helper_Abstract_Config_Settings.php75.00%100.00%100.00%
   Helper_Abstract_Controller.php-100.00%100.00%
   Helper_Abstract_Field_Products.php89.47%66.67%100.00%
   Helper_Abstract_Fields.php93.59%93.75%100.00%
   Helper_Abstract_Fields_Input_Type.php84.00%100.00%100.00%
   Helper_Abstract_Form.php--100.00%
   Helper_Abstract_Model.php100.00%100.00%100.00%
   Helper_Abstract_Options.php74.73%75.00%100.00%
   Helper_Abstract_Pdf_Shortcode.php89.52%91.67%100.00%
   Helper_Abstract_View.php95.83%100.00%100.00%
   Helper_Data.php96.57%100.00%100.00%
   Helper_Field_Container.php92.31%100.00%100.00%
   Helper_Field_Container_Gf25.php82.22%100.00%100.00%
   Helper_Field_Container_Void.php16.67%-100.00%
   Helper_Form.php70.97%64.29%100.00%
   Helper_Interface_Actions.php-100.00%100.00%
   Helper_Interface_Config.php50.00%100.00%100.00%
   Helper_Interface_Config_Settings.php50.00%100.00%100.00%
   Helper_Interface_Extension_Settings.php-100.00%100.00%
   Helper_Interface_Extension_Uninstaller.php-100.00%100.00%
   Helper_Interface_Field_Pdf_Config.php50.00%100.00%100.00%
   Helper_Interface_Filters.php-100.00%100.00%
   Helper_Interface_Setup_TearDown.php-100.00%100.00%
   Helper_Interface_Url_Signer.php-100.00%100.00%
   Helper_Logger.php-100.00%100.00%
   Helper_Misc.php73.12%90.63%100.00%
   Helper_Mpdf.php50.00%100.00%100.00%
   Helper_Notices.php79.31%78.57%100.00%
   Helper_Options_Fields.php96.41%94.12%100.00%
   Helper_PDF.php89.66%94.29%100.00%
   Helper_PDF_List_Table.php84.50%92.31%100.00%
   Helper_Pdf_Queue.php84.31%100.00%100.00%
   Helper_QueryPath.php80.00%100.00%100.00%
   Helper_Sha256_Url_Signer.php87.50%100.00%100.00%
   Helper_Singleton.php90.00%100.00%100.00%
   Helper_Templates.php96.43%100.00%100.00%
   Helper_Trait_Logger.php--100.00%
   Helper_Url_Signer.php82.18%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Licensing
   EDD_SL_Plugin_Updater.php96.64%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Log
   Logger.php70.10%100.00%100.00%
   MonoLoggerPsrLog2And3.php--100.00%
   Redact_Processor.php100.00%100.00%100.00%
/var/www/html/wp-content/plugins/gravity-pdf/src/Helper/Mpdf
   Cache.php66.67%100.00%100.00%
Table truncated to fit comment

🤖 PHPUnit coverage report

@jakejackson1 jakejackson1 force-pushed the phpunit-refactor-squashed branch 6 times, most recently from 6113ff0 to 84e83e0 Compare June 4, 2026 01:00
End-to-end refactor of the PHPUnit suite and CI workflow. Headline outcomes:

Test architecture
- Mirror src/ 1:1 with Test_*.php naming; 32 root-level test-*.php files relocated to per-class files under tests/phpunit/integration/.
- Phase 4 characterization coverage for Controllers, Models, Helpers (Fields/Fonts), and Views; final coverage 81.57% (gate 81.45%).
- New AjaxTestCase parallel to WP_Ajax_UnitTestCase; shared HasGfpdfFixtures trait exposes form()/entry()/entries() accessors to both base classes.
- Skipped trivial exception classes and pure template wrappers per the documented "test if non-trivial" rule.
- tests/phpunit/README.md documents the suite layout, fixtures, and the available fixture keys.

Fixtures-to-factory migration (follow-up epic)
- Removed the suite-scoped $GLOBALS['GFPDF_Test'] global across 62 test files; bootstrap's create_stubs() deleted along with the orphan gravityform-2.json fixture.
- Replaced with per-class static::load_fixtures() declarations populating a protected $fixture_caches map on HasGfpdfFixtures.
- Two factory import paths preserved: import_and_get (array-wrapped GF-export JSON) and import_fixture_and_get (raw-object JSON used by load_fixtures).
- CI grep gate in .github/workflows/tests.yml blocks regression to \$GLOBALS['GFPDF_Test'], GFAPI::add_form, GFAPI::add_entry in test files.
- Suite is 1503 tests / ~4750 assertions / 14 skipped — ~40s single-site, ~38s multisite. Runtime improved vs the +10% budget because bootstrap no longer eagerly creates 7 forms + 5 entry sets.

Suite speed + stability
- Killed the sleep(1) flake in Test_Url_Signer; lifted gf_factory writes to class scope.
- Blocked external HTTP and stripped WP update probes from AJAX setup.
- Unique zip names per Test_Templates stage to kill cross-test flake.
- Closed leak vectors and shaved wall-clock across the suite; post-Phase-4 flake budget is zero.
- Dropped vendored Polls/Quiz/Survey plugins, replaced with a minimal class-stub surface for PHPUnit.

CI infrastructure
- Consolidated PHPUnit + Playwright + JS test workflows into a single tests.yml; extended deps update workflow.
- PR coverage now renders inline via lucassabreu/comment-coverage-clover (Codecov + token removed); coverage-merge.php unions single-site + multisite Clover before the comment step.
- tools/phpunit/retry.sh re-runs only the failing Class::method names parsed from JUnit XML once on flake; retries surface as ::warning::retry: annotations. --coverage-clover stripped from retry args so the full-suite Clover isn't overwritten by a single-test subset.
- wp-env Docker base images (wordpress:php<v>, wordpress:cli-php<v>, mariadb:lts) cached via docker save/load, removing ~60-90s per matrix cell / Playwright shard. docker/setup-buildx-action@v3 dropped — wp-env never used it.
- PHP floor wired to 7.4 in composer.json to match the Gravity Forms requirement.
- setup-php now matches \${{ matrix.php }} instead of hardcoded 7.4.
- Docker Hub pulls routed through Google's mirror to dodge rate limits.
- run-tests-php-all PR label opts into the full PHP-version matrix on demand (cron still runs it weekly); multisite runs on declarative floor (7.4) + ceiling (8.5) cells rather than the 8.3 coverage cell.

Known follow-ups (separate epics)
- Phase 6 Model_PDF refactor.
- 6 pre-existing order-coupled failures surface under --order-by=random (Test_Templates filesystem state, Test_Uninstaller/Test_Actions notices, Test_Rest_Pdf_Preview) — hidden by deterministic discovery order in the legacy suite; not introduced by this work.

Plans: .claude/plans/2026-05-25-phpunit-tests-refactor.md, .claude/plans/2026-05-26-fixtures-to-factory-migration.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jakejackson1 jakejackson1 force-pushed the phpunit-refactor-squashed branch from 84e83e0 to 2228837 Compare June 4, 2026 01:24
@jakejackson1 jakejackson1 merged commit d3af32f into development Jun 4, 2026
18 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.

1 participant