Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: PhpUnitAttributesFixer - handle parentheses after data provider method name#8510

Merged
kubawerlos merged 4 commits into
PHP-CS-Fixer:masterfrom
6b7562617765726c6f73:fix_PhpUnitAttributesFixer
Mar 21, 2025
Merged

fix: PhpUnitAttributesFixer - handle parentheses after data provider method name#8510
kubawerlos merged 4 commits into
PHP-CS-Fixer:masterfrom
6b7562617765726c6f73:fix_PhpUnitAttributesFixer

Conversation

@kubawerlos
Copy link
Copy Markdown
Member

Fixes #8509

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 17, 2025

Coverage Status

coverage: 94.866% (-0.01%) from 94.876%
when pulling 2f10975 on 6b7562617765726c6f73:fix_PhpUnitAttributesFixer
into c3d07b5 on PHP-CS-Fixer:master.

Comment on lines +709 to +710
#[\PHPUnit\Framework\Attributes\DataProvider('provideFooCases()')]
#[\PHPUnit\Framework\Attributes\DataProviderExternal(AnotherTest::class, 'provideBarCases()')]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't it be like this?

Suggested change
#[\PHPUnit\Framework\Attributes\DataProvider('provideFooCases()')]
#[\PHPUnit\Framework\Attributes\DataProviderExternal(AnotherTest::class, 'provideBarCases()')]
#[\PHPUnit\Framework\Attributes\DataProvider('provideFooCases')]
#[\PHPUnit\Framework\Attributes\DataProviderExternal(AnotherTest::class, 'provideBarCases')]

(in order to fail pipeline and show that it does not work as expected right now).

Copy link
Copy Markdown
Member Author

@kubawerlos kubawerlos Mar 17, 2025

Choose a reason for hiding this comment

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

When the bug results in valid syntax I prefer to show the incorrect change rather than the failed pipeline. For 2 reasons:

  1. Paraunit is not showing diffs (so I have to modify ci.yaml to run PHPUnit with the single file for such commit)
  2. CI results will expire one day, when the commits in PR will stay with us.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then maybe there should be 3 commits:

  • test case with existing, invalid behaviour (CI green)
  • changes in expectation (CI red)
  • actual fix (CI green)

First 2 commits could be pushed together IMHO, as most interesting is to show it does not work as expected (first commit would be mostly for historical reasons). Then the 3rd commit provides a solution. This way it would either show wrong behaviour (1st commit) and correct behaviour (2nd and 3rd commit).

But it's up to you.

@Wirone Wirone added topic/phpunit Fixers related to PHPUnit topic/attributes PHP8 native attributes labels Mar 17, 2025
@kubawerlos kubawerlos marked this pull request as ready for review March 17, 2025 14:02
@kubawerlos kubawerlos enabled auto-merge (squash) March 17, 2025 14:08
@kubawerlos kubawerlos merged commit 538f675 into PHP-CS-Fixer:master Mar 21, 2025
@kubawerlos kubawerlos deleted the fix_PhpUnitAttributesFixer branch March 21, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug topic/attributes PHP8 native attributes topic/phpunit Fixers related to PHPUnit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PhpUnitAttributesFixer - remove parentheses as they appear

4 participants