Skip to content

build: declare PHPUnit and Polyfills as composer dependencies - #150

Merged
josephfusco merged 6 commits into
WordPress:mainfrom
i-am-chitti:issue-148
Aug 5, 2026
Merged

build: declare PHPUnit and Polyfills as composer dependencies#150
josephfusco merged 6 commits into
WordPress:mainfrom
i-am-chitti:issue-148

Conversation

@i-am-chitti

Copy link
Copy Markdown
Contributor

Description

Currently, running tests locally via npm run test fails for local developers with a fatal error on a fresh install:

Error: The PHPUnit Polyfills library is a requirement for running the WP test suite.
The PHPUnit Polyfills autoload file was not found in "/var/www/html/vendor/yoast/phpunit-polyfills"

This occurs because:

  1. yoast/phpunit-polyfills and phpunit are not declared in composer.json.
  2. The core tests container setup expects these to be in /var/www/html/vendor/, which is only installed on-the-fly during CI runs.

This PR cleans up the local development and CI testing environments by:

  • Adding phpunit/phpunit and yoast/phpunit-polyfills as dev dependencies inside composer.json.
  • Pointing .wp-env.json to look inside the mounted plugin's vendor folder for the polyfills.
  • Updating package.json to execute ./vendor/bin/phpunit (PHPUnit 9) instead of the WordPress core vendor path. wp-env starts with a standard WordPress ZIP download by default, which does not contain a vendor/ directory inside /var/www/html .
  • Aligning both GitHub Action workflows (phpunit.yml and multisite.yml) to run a standard composer install --no-interaction and run ./vendor/bin/phpunit. This removes the slow and redundant container-level composer require run.

Fixes

How to Test / Verification

  1. Install dependencies:
    composer install
  2. Execute the tests:
    npm run test
  3. Verify that the tests boot correctly and all unit tests run and pass.

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini 3.5 Flash
Used for: Identifying the local test suite provisioning failure, and find regression issue like adjusting the GitHub Action workflows to use standard composer install. Each change has been humanly reviewed by me.

@i-am-chitti
i-am-chitti requested a review from josephfusco as a code owner July 27, 2026 18:12
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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 iamchitti, joefusco.

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

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.13%. Comparing base (3a2ae99) to head (f449299).
⚠️ Report is 33 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #150      +/-   ##
============================================
+ Coverage     28.56%   29.13%   +0.56%     
- Complexity      161      164       +3     
============================================
  Files            15       15              
  Lines          1817     1840      +23     
============================================
+ Hits            519      536      +17     
- Misses         1298     1304       +6     
Flag Coverage Δ
phpunit 29.13% <ø> (+0.56%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@josephfusco josephfusco added [Type] Bug An existing feature is broken Infrastructure Issues for the repository infrastructure github_actions Pull requests that update GitHub Actions code dependencies Pull requests that update a dependency file labels Jul 27, 2026
@josephfusco josephfusco changed the title Build: Declare PHPUnit and Polyfills as composer dependencies build: declare PHPUnit and Polyfills as composer dependencies Jul 31, 2026
@josephfusco josephfusco added [Type] Enhancement A suggestion for improvement of an existing feature and removed [Type] Bug An existing feature is broken labels Jul 31, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

▶ Preview in WordPress Playground

Open in WordPress Playground

Boots a fresh WordPress with this PR's presence-api build, seeds 5 demo users, and drops you on the dashboard.

Stress-test variant: 40 demo users · Built from f449299b15a3682cd98f19714897099062db6d7b. Auto-updates when you push.

@josephfusco
josephfusco merged commit 0636200 into WordPress:main Aug 5, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code Infrastructure Issues for the repository infrastructure [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants