Skip to content

Conversation

@OskarStark
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Docs? no
Issues --
License MIT

Configure php_unit_test_annotation and php_unit_attributes rules to enforce modern PHPUnit attribute syntax and remove test prefixes from methods that use the #[Test] attribute.

cc @valtzu

Configure php_unit_test_annotation and php_unit_attributes rules
to enforce modern PHPUnit attribute syntax and remove test prefixes
from methods that use the #[Test] attribute.
@OskarStark OskarStark changed the title Add PHP CS Fixer rules for PHPUnit attributes Add PHP-CS-Fixer rules for PHPUnit attributes Jul 24, 2025

#[Test]
public function testGetMetadataNotExistingClass(): void
public function getMetadataNotExistingClass(): void
Copy link
Member

@nicolas-grekas nicolas-grekas Jul 24, 2025

Choose a reason for hiding this comment

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

that's strange to me, it blurs the line between test cases and helper methods
we should also consider making the practices on symfony/symfony and symfoyn/ai converge
this looks diverging here to me

Copy link
Member

Choose a reason for hiding this comment

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

I agree. Having a void method with a get name prefix feels espcially weird.

Copy link
Member

Choose a reason for hiding this comment

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

this is mostly about (not) having the test* prefix in the method name, not about the void, right?

i don't have a real preference other than being more used to having the prefix over the attribute, but mostly care about streamlining here :)

@OskarStark any hard feelings about going the symfony/symfony way here?

Copy link
Member

Choose a reason for hiding this comment

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

this is mostly about (not) having the test* prefix in the method name

Yes.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that the new method names are confusing.
I don't think using the Test attribute makes things better.

@chr-hertel
Copy link
Member

chr-hertel commented Jul 27, 2025

Closed in favor of #214

@chr-hertel chr-hertel closed this Jul 27, 2025
chr-hertel added a commit that referenced this pull request Jul 27, 2025
This PR was merged into the main branch.

Discussion
----------

Replace #[Test] attribute by test prefix

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Docs?         | no
| Issues        |
| License       | MIT

Replacing #196

| Component | `main` | `test-prefix` | |
| ---------- | ------ | -------------- | - |
| Agent |105 tests, 287 assertions | 105 tests, 287 assertions | ✔️ |
| AI Bundle | 14 tests, 34 assertions | 14 tests, 34 assertions | ✔️ |
| MCP Bundle | no tests | still no tests | 😞 |
| MCP SDK | 23 tests, 57 assertions | 23 tests, 57 assertions | ✔️ |
| Platform | 381 tests, 801 assertions | 381 tests, 801 assertions | ✔️ |
| Store | 90 tests, 411 assertions | 90 tests, 411 assertions | ✔️ |

Commits
-------

2f7320d Replace #[Test] attribute by test prefix
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.

5 participants