Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: AutoReview - unify data provider returns #7544

Merged
merged 6 commits into from Dec 10, 2023

Conversation

keradus
Copy link
Member

@keradus keradus commented Dec 10, 2023

inspired by #7542

@keradus keradus changed the title tests: AutoReview - unify data provider returns test: AutoReview - unify data provider returns Dec 10, 2023
@keradus keradus marked this pull request as ready for review December 10, 2023 22:21
@coveralls
Copy link

coveralls commented Dec 10, 2023

Coverage Status

coverage: 94.908%. remained the same
when pulling dcb3b47 on keradus:phpunit_provider
into d7f6ea9 on PHP-CS-Fixer:master.

Copy link
Member

@Wirone Wirone left a comment

Choose a reason for hiding this comment

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

I am wondering if it wouldn't be possible to introduce a fixed contract for fixers' test classes (like define provideFixCases, provideFix80Cases etc) with proper return type and only override the body (actual cases) in tests 🤔. That would be better than defining the same/similar phpDoc hundred of times.

Anyway, I did not do a full review, just wanted to give some feedback.

/**
* @dataProvider provideTestClassCases
*/
public function testDataPorvidersDeclaredReturnType(string $testClassName): void
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function testDataPorvidersDeclaredReturnType(string $testClassName): void
public function testDataProvidersDeclaredReturnType(string $testClassName): void

Anyway, why do we need this test? Isn't PHPStan checking this?

Copy link
Member Author

Choose a reason for hiding this comment

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

looking on amount of changes, PHPStan is not checking it.

Copy link
Member

Choose a reason for hiding this comment

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

Mental shortcut - PHPStan requires more precise iterable type and IMHO it could be sufficient. For new providers we rather define good array shapes, all currently ignored missing types also could be added properly. If I understand correctly you just wanted to ensure really, really precise array shape?

Copy link
Member Author

@keradus keradus Dec 11, 2023

Choose a reason for hiding this comment

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

yep, I wanted to avoid array<int> when we have only one int, so array{int}.
some side wins on the go also, like return array vs list vs iterable unification.
now (With this PR), for data providers, we either have no phpdoc (and simply rely on : iterable), or we have nice iterable of tuples

@@ -452,6 +452,56 @@ public function testExpectedInputOrder(string $testClassName): void
}
Copy link
Member Author

@keradus keradus Dec 10, 2023

Choose a reason for hiding this comment

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

I am wondering if it wouldn't be possible to introduce a fixed contract for fixers' test classes

Overall, sounds valid.

I think the pre-step for it is unification of prototypes (eg in this PR we see config, expected, input -> expected, input, config (yet not claiming this PR unifies everything) and test method names (especially around @requires PHP xyz)

And if for some cases we could not reuse contract, the custom-type could help
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7544/files#diff-a4ce6ffd8cb697aecebba7af3c784ed29078f645544c069ec7fecbe9417e2a04R20

@keradus keradus merged commit 095443e into PHP-CS-Fixer:master Dec 10, 2023
25 checks passed
@keradus keradus deleted the phpunit_provider branch December 10, 2023 23:07
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.

None yet

3 participants