Skip to content

Update how we run PHPUnit#1053

Merged
peterwilsoncc merged 14 commits intodevelopfrom
update/phpunit-workflow
Feb 16, 2026
Merged

Update how we run PHPUnit#1053
peterwilsoncc merged 14 commits intodevelopfrom
update/phpunit-workflow

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Feb 12, 2026

Description of the Change

Our PHPUnit workflow has started to fail and in investigating that, seems GitHub has updated their default version of Docker that is installed in their runners and that is conflicting with the tool we use to run our tests. That tool hasn't been updated since June 2024 so I'm not confident they'll push out a fix.

Also, there's a better way to run PHPUnit tests now that didn't exist/we didn't know about when we set this up (using wp-env) so this is a good opportunity to clean up that setup.

The following updates are made:

  • We update our GitHub Action workflow to use the wp-env environment to run our PHPUnit tests (and run those on a wider matrix)
  • Update our various config and bootstrap files as needed
  • Fixed a few tests that started failing now that we're running tests (both unit and E2E) with debug turned on
  • Rename our test directory to Integration (previously was Classifai)

Note most of this was copied from the approach we take on the AI Experiments plugin.

How to test the Change

Ensure the PHPUnit GitHub Action runs and passes on this PR

Changelog Entry

Developer - Update our PHPUnit workflow

Credits

Props @dkotter

Checklist:

@dkotter dkotter added this to the 3.8.0 milestone Feb 12, 2026
@dkotter dkotter self-assigned this Feb 12, 2026
@dkotter dkotter requested review from a team and jeffpaul as code owners February 12, 2026 22:48
@github-actions github-actions bot added the needs:code-review This requires code review. label Feb 12, 2026
@github-actions
Copy link

github-actions bot commented Feb 12, 2026

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@dkotter dkotter requested review from peterwilsoncc and removed request for a team and jeffpaul February 13, 2026 00:16
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions and a minor quibble inline.

PHP Unit is generating the files and folders below that will need to be added the ignore file.

tests/_output/html/
tests/_output/php-coverage.xml

I'm able to get the tests running using both Chassis and WP-Env. On WP-Env I'm getting the message Warning: No code coverage driver available so you may need to add something to the config file.

Comment on lines +26 to +29
include:
- php: '8.4'
wp: latest
coverage: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be covered by the matrix, why is it needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I had coverage: true here, so the coverage report would be generated only on PHP 8.4 and WP latest. But our test coverage is currently so low that the report isn't super useful so I changed this to false and yeah, no need to have this now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in f18f9a6

$response = file_get_contents( __DIR__ . '/image_analyze.json' );
} elseif ( strpos( $url, 'http://e2e-test-image-processing.test/vision/v3.2/generateThumbnail' ) !== false ) {
$response = file_get_contents( __DIR__ . '../classifai/assets/img/icon256x256.png' );
$response = file_get_contents( '/var/www/html/wp-content/plugins/classifai/assets/img/icon-256x256.png' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an open source project, I think it would be good to keep this relative to __DIR__ to account for people using different environments to run the tests on.

It's not a hill I will die on though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is it seems this code never worked and we just never realized it. Now that our test environment runs with debug on, this started causing failures and I realized it was broken (and thus fixed it here). It seems the path traversal doesn't work (or I couldn't get it to work) so easy answer was this. But I can also just copy this image into our test directory and load it from there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 2ddd7cb

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice it yesterday but I now see the typo in the original code, it was __DIR__' . '../' rather than __DIR__ ' . '/../'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there were two typos, a missing slash (__DIR__ . '../classifai vs __DIR__ . '/../classifai) and a missing dash in the filename (icon256x256.png vs icon-256x256.png). I swear I fixed both of those yesterday and tests were still failing locally but trying again today things work so 🤷🏻

In any case, this has been updated now to use the correct image path: 20c50a1

(p.s. thanks for sticking with this one)

@dkotter
Copy link
Collaborator Author

dkotter commented Feb 13, 2026

A couple of questions and a minor quibble inline.

PHP Unit is generating the files and folders below that will need to be added the ignore file.

Added in 45bd2ce

I'm able to get the tests running using both Chassis and WP-Env. On WP-Env I'm getting the message Warning: No code coverage driver available so you may need to add something to the config file.

So this can be fixed by running npm run env start -- --xdebug=coverage when we start our test environment. I'm currently not doing that as we're not using the coverage reports for anything (and this causes things to be slightly slower). But if you think having those coverage reports is useful, I can change this.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this can be fixed by running npm run env start -- --xdebug=coverage when we start our test environment. I'm currently not doing that as we're not using the coverage reports for anything (and this causes things to be slightly slower). But if you think having those coverage reports is useful, I can change this.

That makes sense to me.

This looks good to merge.

@peterwilsoncc peterwilsoncc merged commit 61aa6cb into develop Feb 16, 2026
28 checks passed
@peterwilsoncc peterwilsoncc deleted the update/phpunit-workflow branch February 16, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants