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

InvalidAbstractName should not throw error on *TestCase class #121

Closed
soullivaneuh opened this issue Jan 25, 2018 · 4 comments
Closed

InvalidAbstractName should not throw error on *TestCase class #121

soullivaneuh opened this issue Jan 25, 2018 · 4 comments

Comments

@soullivaneuh
Copy link
Contributor

Example:

FILE: /code/tests/Security/Authorization/Voter/VoterTestCase.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 16 | ERROR | Abstract class name is not prefixed with "Abstract"
----------------------------------------------------------------------

But it's not true. See Symfony code source. *TestCase classes are not prefixed by Abstract.

Workaround:

<rule ref="Symfony.NamingConventions.ValidClassName.InvalidAbstractName">
    <exclude-pattern>*TestCase.php</exclude-pattern>
</rule>
@wickedOne
Copy link
Contributor

as stated over here as well, personally i don't think referencing to symfony's test case classes or code in general is a valid reason for an adapted version of what is stated in their coding standard.

you can easily exclude your test case files if you don't agree with the coding standard if it comes to unit tests. disabling the rule by default would "break" this coding standard to those who actually want to apply the same rules to both their regular code and their test cases...

@hkdobrev
Copy link
Contributor

From Symfony coding standard:

Prefix all abstract classes with Abstract except PHPUnit *TestCase. Please note some early Symfony classes do not follow this convention and have not been renamed for backward compatibility reasons. However all new abstract classes must follow this naming convention;

https://symfony.com/doc/current/contributing/code/standards.html

I'd like to enforce that rule in our own code with this standard, but it requires abstract test cases to have the abstract prefix as well.

@soullivaneuh
Copy link
Contributor Author

disabling the rule by default would "break"

I'm not talking about disabling the rule but make an exception on TestCase classes.

@djoos
Copy link
Owner

djoos commented Sep 11, 2018

Thanks for this thread - IMO the coding standard shouldn't provide the exclusion, which goes against what the standard sets out (ie. an abstract class name needs to be not prefixed with "Abstract"). With that in mind, I'd push that back to your CI setup to have TestCase classes checked differently.

Hope this helps!

@djoos djoos closed this as completed Sep 11, 2018
This issue was closed.
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

No branches or pull requests

4 participants