Update PHPUnit and PHPCS setup to match wordpress-activitypub#302
Merged
Update PHPUnit and PHPCS setup to match wordpress-activitypub#302
Conversation
- Update composer.json with modern dev dependencies and scripts - Update GitHub Actions workflows for PHP 7.4-8.4 compatibility - Add comprehensive PHPDoc documentation to all PHP files - Restructure tests to tests/phpunit/tests/includes/ directory - Rename test files to class-test-*.php convention - Update phpcs.xml with improved rule configuration - Update phpunit.xml.dist with new test paths
Contributor
There was a problem hiding this comment.
Pull request overview
Modernizes the plugin’s QA/tooling setup (Composer dev deps/scripts, PHPCS, PHPUnit config, and GitHub Actions) and reorganizes/renames the PHPUnit test suite while adding/refreshing PHPDoc across the codebase.
Changes:
- Updated Composer dev dependencies and scripts; adjusted PHPCS and PHPUnit configuration.
- Reworked GitHub Actions workflows for linting and test execution across multiple PHP/WP/ClassicPress versions.
- Restructured PHPUnit tests under
tests/phpunit/tests/includes/and added/updated PHPDoc across many PHP sources.
Reviewed changes
Copilot reviewed 29 out of 42 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/phpunit/tests/includes/class-test-userinfo-endpoint.php | Adds UserInfo endpoint PHPUnit coverage under new test layout. |
| tests/phpunit/tests/includes/class-test-tokens.php | Adds Token_User storage tests under new conventions. |
| tests/phpunit/tests/includes/class-test-token-endpoint.php | Adds token endpoint integration tests under new test layout. |
| tests/phpunit/tests/includes/class-test-ticket-endpoint.php | Adds ticket endpoint tests under new test layout. |
| tests/phpunit/tests/includes/class-test-revocation-endpoint.php | Adds revocation endpoint tests under new test layout. |
| tests/phpunit/tests/includes/class-test-introspection-endpoint.php | Adds introspection endpoint tests under new test layout. |
| tests/phpunit/tests/includes/class-test-functions.php | Adds tests for helper/validation functions. |
| tests/phpunit/tests/includes/class-test-discovery.php | Adds discovery tests for rel parsing/link discovery. |
| tests/phpunit/tests/includes/class-test-authorize.php | Adds authorization/authentication behavior tests. |
| tests/phpunit/tests/includes/class-test-auth-endpoint.php | Adds tests for auth endpoint redemption & PKCE verifier. |
| tests/phpunit/bootstrap.php | Introduces new PHPUnit bootstrap for WP test environment. |
| phpunit.xml.dist | Updates bootstrap path and test suite discovery; adds coverage config. |
| phpcs.xml | Updates PHPCS ruleset, excludes, and compatibility configuration. |
| indieauth.php | Adds package docs and normalizes inline comments/PHPDoc. |
| includes/functions.php | Adds/updates PHPDoc and tightens sanitization for header parsing. |
| includes/class-web-signin.php | Adds class/file PHPDoc and method documentation. |
| includes/class-token-user.php | Adds class/file PHPDoc and method/property documentation. |
| includes/class-token-transient.php | Adds class/file PHPDoc and improves cookie input sanitization. |
| includes/class-token-list-table.php | Adds class/file PHPDoc and method documentation. |
| includes/class-token-generic.php | Adds class/file PHPDoc and clarifies method contracts. |
| includes/class-oauth-response.php | Adds class/file PHPDoc and improves PHPCS directives/logging annotation. |
| includes/class-indieauth-userinfo-endpoint.php | Adds class/file PHPDoc and sanitizes redirected auth header usage. |
| includes/class-indieauth-token-ui.php | Adds class PHPDoc and minor comment normalization. |
| includes/class-indieauth-token-endpoint.php | Adds class/method PHPDoc and normalizes inline comments. |
| includes/class-indieauth-ticket-endpoint.php | Adds class/method PHPDoc and normalizes inline comments. |
| includes/class-indieauth-scopes.php | Adds class/method PHPDoc and refactors inline comments. |
| includes/class-indieauth-scope.php | Adds class/method PHPDoc and cleans up doc formatting. |
| includes/class-indieauth-revocation-endpoint.php | Adds class/method PHPDoc and normalizes docs/comments. |
| includes/class-indieauth-metadata-endpoint.php | Adds class/method PHPDoc and refactors serve_request docs. |
| includes/class-indieauth-introspection-endpoint.php | Adds class/method PHPDoc and normalizes docs/comments. |
| includes/class-indieauth-endpoint.php | Adds class/method PHPDoc around token helpers and header helpers. |
| includes/class-indieauth-client-taxonomy.php | Adds class/method PHPDoc and normalizes comments. |
| includes/class-indieauth-client-discovery.php | Fixes docblock termination for discovery parsing docs. |
| includes/class-indieauth-authorize.php | Adds class/method PHPDoc and normalizes comments. |
| includes/class-indieauth-authorization-endpoint.php | Adds class/method PHPDoc and refactors inline comments. |
| includes/class-external-token.php | Minor doc formatting normalization. |
| includes/class-external-token-page.php | Adds class/file PHPDoc for external token UI page. |
| composer.json | Updates PHP requirement and dev tooling deps/scripts for lint/test. |
| .gitignore | Ignores PHPUnit cache file. |
| .github/workflows/wp-phpunit.yml | Updates WP PHPUnit workflow triggers and environment setup. |
| .github/workflows/phpcs.yml | Updates PHPCS workflow triggers and execution. |
| .github/workflows/cp-phpunit.yml | Updates ClassicPress PHPUnit workflow triggers and execution. |
Comments suppressed due to low confidence (2)
includes/class-indieauth-client-taxonomy.php:360
str_contains()is PHP 8+ only, but the project declares/supports PHP 7.2. This will fatal on older runtimes. Use a PHP 7-compatible substring check (e.g.,false !== strpos(...)).
// If the URL is inside the upload directory.
if ( str_contains( self::upload_directory( '', true ), $url ) ) {
return $url;
includes/class-indieauth-metadata-endpoint.php:77
str_contains()is used here, but the project declares/supports PHP 7.2 incomposer.json/CI.str_contains()is only available in PHP 8+, so this will fatal on PHP 7.2/7.4. Replace with a PHP 7-compatible check (e.g.,false !== strpos(...)).
public static function serve_request( $served, $result, $request, $server ) {
if ( ! str_contains( $request->get_route(), '/indieauth/1.0' ) ) {
return $served;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix deregister_scope() bug using literal key instead of variable - Fix composer.json allow-plugins placement and add missing installer - Fix CI matrix configs for wp-version and cp-version axes - Replace PHPUnit <coverage> with <filter><whitelist> for PHPUnit 8 - Replace str_contains() with strpos() for PHP 7.2 compatibility - Add SSRF protection via wp_http_validate_url() on ticket endpoint - Add PHPDoc comments to all undocumented classes, methods, properties - Fix input sanitization with wp_unslash/sanitize_text_field/isset - Fix inline comments, reserved keyword params, urlencode usage - Rename class-external-token.php to match class name convention - Fix bootstrap paths for tests/phpunit/ directory structure - Update .wp-env.json with proper test mappings matching activitypub - Update package.json scripts and wp-env version - Delete .codeclimate.yml, .distignore, .svnignore - Update .gitattributes with comprehensive export-ignore rules - Add github-actions ecosystem to dependabot.yml
The haystack and needle were swapped — should check if $url contains the upload directory path, not the other way around.
…nfig
- Remove sanitize_text_field() from authorization headers to avoid
corrupting Bearer tokens — wp_unslash() is sufficient for non-HTML values
- Remove debug error_log('Pre-Parse'/'Post-Parse') calls from client discovery
- Pin WPCS to ^3.0 instead of unstable dev-develop branch
- Remove deprecated PHPUnit convertErrorsToExceptions attributes
- Add fail-fast: false to WP PHPUnit workflow matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/phpunit/tests/includes/directoryclass-test-*.phpconventionTest plan
composer lintpassescomposer testpasses