Skip to content

Update PHPUnit and PHPCS setup to match wordpress-activitypub#302

Merged
pfefferle merged 6 commits intotrunkfrom
update/phpunit-phpcs-setup
Mar 31, 2026
Merged

Update PHPUnit and PHPCS setup to match wordpress-activitypub#302
pfefferle merged 6 commits intotrunkfrom
update/phpunit-phpcs-setup

Conversation

@pfefferle
Copy link
Copy Markdown
Member

Summary

  • 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

Test plan

  • Verify composer lint passes
  • Verify composer test passes
  • Verify GitHub Actions workflows run successfully

- 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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 in composer.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.

Comment thread includes/class-indieauth-scopes.php Outdated
Comment thread composer.json Outdated
Comment thread .github/workflows/wp-phpunit.yml
Comment thread phpunit.xml.dist Outdated
Comment thread .github/workflows/cp-phpunit.yml Outdated
Comment thread includes/class-indieauth-ticket-endpoint.php
- 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
@pfefferle pfefferle merged commit bf808b2 into trunk Mar 31, 2026
8 checks passed
@pfefferle pfefferle deleted the update/phpunit-phpcs-setup branch March 31, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants