Skip to content

Add GitHub Actions workflow to validate PHPUnit test file conventions. - #13466

Open
pbearne wants to merge 9 commits into
WordPress:trunkfrom
pbearne:65208-action-namespace-validations
Open

Add GitHub Actions workflow to validate PHPUnit test file conventions.#13466
pbearne wants to merge 9 commits into
WordPress:trunkfrom
pbearne:65208-action-namespace-validations

Conversation

@pbearne

@pbearne pbearne commented Sep 9, 2026

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/65208

Description

Adds a dedicated GitHub Actions workflow (.github/workflows/validate-phpunit-cleanup-pr.yml) to automatically validate that PHPUnit test files added or updated in pull requests comply with the core test modernization specification (#65208, #53010).

Automated Checks Performed:

  • File Path Hierarchy: Validates that test files adhere to the standardized directory structure under tests/phpunit/tests/:
    • For class methods: tests/phpunit/tests/wp-[includes|admin]/[SubFolder/]*Class_Under_Test/FunctionUnderTest[OptionalSubsetIndicator]Test.php
    • For procedural functions: tests/phpunit/tests/wp-[includes|admin]/[SubFolder/]*Functions_FileName/FunctionUnderTest[OptionalSubsetIndicator]Test.php
  • Namespace Compliance: Ensures all test files declare a valid PSR-4 namespace starting with WordPress\Tests\... that strictly maps to the directory structure.
  • Class Naming & Granularity:
    • Enforces single-class-per-file granularity.
    • Verifies that class names end with Test and match their filename exactly (FunctionUnderTest[OptionalSubsetIndicator]Test).
  • Support File Exclusions: Automatically skips test helper/harness files (such as base.php), mock fixtures, and data directories.

Testing Instructions

  1. Review workflow trigger configuration and permissions in .github/workflows/validate-phpunit-cleanup-pr.yml.
  2. Open or update a pull request modifying test files under tests/phpunit/tests/ to trigger the Validate PHPUnit Test Cleanup Files workflow.
  3. Verify that test files following the specification pass with success summaries, while non-compliant files or namespaces produce clear, actionable error logs.

AI Disclosure

  • AI assistance: Yes
  • Tool(s): JetBrains Junie
  • Model(s): Gemini 2.5 Flash
  • Used for: Developing the GitHub Actions workflow definition and JavaScript validation logic for test structure compliance.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @pbearne@git.wordpress.org.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props pbearne.

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

Comment thread .github/workflows/validate-phpunit-cleanup-pr.yml Fixed
Comment thread .github/workflows/validate-phpunit-cleanup-pr.yml Fixed
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