close
Skip to content

Add ValidTestClassName sniff to enforce test class naming conventions#2595

Closed
prab18hat wants to merge 1 commit intoWordPress:developfrom
prab18hat:feature/test-class-naming-conventions
Closed

Add ValidTestClassName sniff to enforce test class naming conventions#2595
prab18hat wants to merge 1 commit intoWordPress:developfrom
prab18hat:feature/test-class-naming-conventions

Conversation

@prab18hat
Copy link

Fixes #2484

This PR adds a new sniff WordPress.NamingConventions.ValidTestClassName that enforces consistent test class naming across the codebase.

What's included:

  • Ensures test class names end with 'Test'
  • Requires PascalCase for class names
  • Verifies class names match their filenames
  • Only checks classes that extend test case classes (PHPUnit or WP_UnitTestCase)
  • Includes comprehensive test cases

Testing:

  • Added unit tests for valid and invalid test class names
  • Verified the sniff works with different test case class extensions
  • Confirmed it only runs on test files (*Test.php)

- Ensures test class names end with 'Test'
- Requires PascalCase for class names
- Verifies class names match filenames
- Only checks classes extending test case classes
- Includes comprehensive test cases
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

@prab18hat Thank you for your interest in contributing to the WordPress Coding Standards project.

Unfortunately, this PR will not be merged.

  • ❌ It shows no understanding of the existing codebase.
  • ❌ It doesn't use the available utility methods.
  • ❌ It doesn't follow the correct test conventions.
  • etc

In other words, the amount of coaching which would be needed to get this into an even remotely mergable state is too much.

@jrfnl jrfnl closed this Sep 2, 2025
@prab18hat prab18hat deleted the feature/test-class-naming-conventions branch September 3, 2025 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sniff to check that test class names and test file names comply with PHPUnit naming conventions

2 participants