test: deslop and fix PHPUnit Tests - #189
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Relocates the PHPUnit suite from tests/Unit & tests/Integration to tests/phpunit/..., replaces the bespoke _doing_it_wrong capture helpers with the polyfilled setExpectedIncorrectUsage() API, and rewrites the base TestCase to extend WP_UnitTestCase directly. A number of test fixtures (especially in DummyAbility) are slimmed down and migrated to in-test registration via register_ability_in_hook(). Configuration files (phpunit.xml.dist, phpstan.neon.dist, .phpcs.xml.dist, composer.json, wp-env JSON, GitHub workflows) are updated to the new layout and to newer dep versions. Also includes unrelated scaffolding cleanup (dependabot, SECURITY.md, gitignore/gitattributes, PR template, removed README-INITIAL.md).
Changes:
- Relocate test suite to
tests/phpunit/and replace customassertDoingItWrongTriggered()helper withsetExpectedIncorrectUsage(); slim downDummyAbilityfixtures with per-test ability registration. - Update tooling configs (PHPUnit/PHPCS/PHPStan paths, wp-env split into
.wp-env.jsonand.wp-env.test.json, pinned action SHAs, Node 22, new composer script names). - Minor production touches:
RequestRoutercallsis_sensitive_keyonErrorLogMcpObservabilityHandlerinstead of the trait;DiscoverAbilitiesAbilityadds PHPCS ignore comments for unused parameters.
Reviewed changes
Copilot reviewed 50 out of 103 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/phpunit/** (most files) | Moved from tests/, reformatted, switched to setExpectedIncorrectUsage, in-test ability registration. |
| tests/TestCase.php, tests/Unit/PluginTest.php | Removed old locations. |
| tests/phpunit/TestCase.php | New base class extending WP_UnitTestCase, simpler setup, no _doing_it_wrong capture. |
| tests/phpunit/Fixtures/Dummy*.php | Re-added at new path; DummyAbility no longer includes resources with old-meta/whitespace/invalid-annotations fixtures (moved into specific tests). |
| tests/phpunit/Stubs/WpCli*.php | New stub classes/utilities for WP-CLI in tests. |
| tests/phpunit/bootstrap.php | Updated paths and now requires the plugin entry directly. |
| tests/phpstan/wp-cli-stubs.stub | Added PHPStan stub for WP_CLI. |
| includes/Transport/Infrastructure/RequestRouter.php | Switched is_sensitive_key call from the trait to ErrorLogMcpObservabilityHandler. |
| includes/Abilities/DiscoverAbilitiesAbility.php | Added PHPCS ignore comments for unused params. |
| composer.json | Renamed scripts (lint, format, phpstan), removed wpackagist repo/plugin-check, bumped phpcompatibility-wp to ^3.0.0-alpha, updated autoload-dev path. |
| phpunit.xml.dist | Updated bootstrap, suite paths, coverage output; dropped mcp-adapter.php from coverage. |
| phpstan.neon.dist | Reformatted, dropped abilities-api sibling scan, switched to local stub file, bumped max PHP to 8.5. |
| .phpcs.xml.dist | Removed plugin-check ruleset, updated prefix list, set min WP to 6.9, exclude _output. |
| .wp-env.json / .wp-env.test.json | Split dev and test environments; new test env on port 8889. |
| package.json | Node 22 requirement; new wp-env:test/wp-env:cli scripts; updated @wordpress/* deps and overrides block. |
| .github/workflows/*.yml | Updated to newer pinned action SHAs and cli env target; PHPStan no longer checks out abilities-api. |
| .github/dependabot.yml, .github/PULL_REQUEST_TEMPLATE.md, SECURITY.md, .npmrc | New project-scaffolding files. |
| .gitignore, .gitattributes, .prettierrc.js, .prettierignore, .nvmrc, docs/guides/testing.md, CONTRIBUTING.md, README-INITIAL.md | Misc scaffolding/docs alignment. |
Comments suppressed due to low confidence (1)
tests/phpunit/Unit/Core/McpAdapterConfigTest.php:425
- Typo in the comment: trailing
4at the end of "test error handling4". Should be just "test error handling".
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #189 +/- ##
============================================
+ Coverage 88.25% 88.44% +0.19%
Complexity 1243 1243
============================================
Files 54 53 -1
Lines 4035 4033 -2
============================================
+ Hits 3561 3567 +6
+ Misses 474 466 -8
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:
|
6f57bf5 to
9afa2f2
Compare
|
Wow our GH settings on this repo are absolute crap... This should have just auto-changed to the base branch. Will ping someone to handle alongside #186 |
|
Moved to #193 |
What
This PR relocates PHPUnit tests to
tests/phpunit, then deslops the internals so tests pass.Important
This PR is based on #185 which should be merged first.
Relevant diff: https://github.com/WordPress/mcp-adapter/pull/189/changes/ab613a08f629dbf9337cbd12115094d6b19ffc3c..9afa2f23e7255d8e7902c0dde23982a3b3a6d004
Why
Tests were failing due to compounding AI-slop around the TestCase.
How
TestCaseto extend the correctWP_UnitTestCase, and use the built-in methods.setExpectedIncorrectUsage()to the tests that should have it.(The goal was not to audit all of the existing tests, just to fix the central issues causing all the failures).