-
Notifications
You must be signed in to change notification settings - Fork 48
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
Strict and opinionated rules for PHPUnit #5
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Otherwise it does not play nice with inline validation in PHPStorm
This is perfect! 😊 I will be able to test it on Slevomat once we upgrade to 0.9. |
Btw what about assertInstanceof + the negative variant? That could also be
enforced 😊
On Thu, 21 Dec 2017 at 17:48, Martin Hujer ***@***.***> wrote:
I've created several rules that suggest better assertions in PHPUnit tests.
I have a few more in the backlog, but I wanted to start small to see if we
are on the same page (and the PR is already tooo long anyway).
I've tested the Rules on @driveto <https://github.com/driveto> codebase
and on PHPStan itself, but it would be great if you can try it on something
bigger (such as @slevomat <https://github.com/slevomat> codebase ;-))
------------------------------
You can view, comment on, or merge this pull request online at:
#5
Commit Summary
- improve AssertSameDifferentTypesRule test coverage
- Move PHPCS exclusion pattern to phpcs.xml
- extract PHPUnit method call detection to helper
- AssertSameNullExpectedRule
- AssertSameBooleanExpectedRule
- AssertSameWithCountRule
File Changes
- *M* README.md
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-0> (13)
- *M* build.xml
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-1> (2)
- *M* phpcs.xml
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-2> (1)
- *A* src/Rules/PHPUnit/AssertRuleHelper.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-3> (52)
- *A* src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-4> (53)
- *M* src/Rules/PHPUnit/AssertSameDifferentTypesRule.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-5> (29)
- *A* src/Rules/PHPUnit/AssertSameNullExpectedRule.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-6> (46)
- *A* src/Rules/PHPUnit/AssertSameWithCountRule.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-7> (49)
- *A* strictRules.neon
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-8> (13)
- *A* tests/Rules/PHPUnit/AssertSameBooleanExpectedRuleTest.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-9> (37)
- *M* tests/Rules/PHPUnit/AssertSameDifferentTypesRuleTest.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-10> (14)
- *A* tests/Rules/PHPUnit/AssertSameNullExpectedRuleTest.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-11> (29)
- *A* tests/Rules/PHPUnit/AssertSameWithCountRuleTest.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-12> (25)
- *A* tests/Rules/PHPUnit/data/Foo.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-13> (13)
- *A* tests/Rules/PHPUnit/data/assert-same-boolean-expected.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-14> (24)
- *A* tests/Rules/PHPUnit/data/assert-same-count.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-15> (18)
- *A* tests/Rules/PHPUnit/data/assert-same-null-expected.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-16> (22)
- *M* tests/Rules/PHPUnit/data/assert-same.php
<https://github.com/phpstan/phpstan-phpunit/pull/5/files#diff-17> (17)
Patch Links:
- https://github.com/phpstan/phpstan-phpunit/pull/5.patch
- https://github.com/phpstan/phpstan-phpunit/pull/5.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuCOumbhdvjPgGW7TjlVHiSqQMBbNks5tCou7gaJpZM4RKE3b>
.
--
Ondřej Mirtes
|
I've created an issue with the list of ideas for additional rules #7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've created several rules that suggest better assertions in PHPUnit tests.
I have a few more in the backlog, but I wanted to start small to see if we are on the same page (and the PR is already tooo long anyway).
I've tested the Rules on @driveto codebase and on PHPStan itself, but it would be great if you can try it on something bigger (such as @slevomat codebase ;-))