My phpcs is worng because when running phpcs this show error about CamelCase on name of tests
16 | ERROR | Method name "RegistrationTest::can_register" is not in camel caps format
16 | ERROR | Visibility must be declared on method "can_register"
I don't like exclude tests/* from phpcs. I've tried some aporach on phpcs.xml but not work I don't understan well how I can do it.
@abkrim It’s not “wrong”. It’s just doing exactly what it’s been instructed to. If you want to disable that rule for tests, then do so.
I don’t know what the rule name is off-hand, but for me in Visual Studio Code it’s displayed in the tooltip when I hover over some code that fails my phpcs configuration. You would then add it to your phpcs.xml (or whatever you’ve called your file) like this:
I know that rule works, but I don't want to exclude all path tests /
What I want is to exclude the use of camel case in the name of the methods in the tests of the path tests / * the error CamelCase in the name of methods (PSR1.Methods.CamelCapsMethodName)
-----------------------------------------------------------------------------------------------------------------------------
16 | ERROR | Visibility must be declared on method "registration_page_contains_livewire_component"
22 | ERROR | Visibility must be declared on method "can_register"
25 | WARNING | Line exceeds 120 characters; contains 154 characters
34 | ERROR | Visibility must be declared on method "email_is_required"
46 | ERROR | Visibility must be declared on method "email_is_valid_email"
58 | ERROR | Visibility must be declared on method "email_hasnt_been_taken_already"
79 | ERROR | Visibility must be declared on method "see_email_hasnt_already_been_taken_validation_message_as_user_types"
98 | ERROR | Visibility must be declared on method "password_is_required"
110 | ERROR | Visibility must be declared on method "password_is_minimum_of_six_characters"
122 | ERROR | Visibility must be declared on method "password_matches_password_confirmation"
134 | ERROR | Visibility must be declared on method "name_is_minimum_of_six_characters"
146 | ERROR | Visibility must be declared on method "name_is_required"
-----------------------------------------------------------------------------------------------------------------------------
if use work with out errors, but not check other rules. (excluded)
@abkrim Right, so what’s the problem? It’s not complaining about camel case method names any more; it’s now complaining about missing visibility statements on your methods. It’s a completely different error.
The question is that with the normal configuration phpcs detects as incorrect the rule that defines the use of CamelCase in the method names.
Of the two options, one what it does is disable phpcs for ALL the test directory.
What you offer me, what it does is eliminate the CamelCase error but the others appear.
The reality is that I want to have the same rules as the normal code, except for the name format of the test methods.
I feel that the problem is one of communication because of the language.
Thanks @martinbean
What you offer me, what it does is eliminate the CamelCase error but the others appear.
Yes. You’ve disabled the rule for camel case names, now you have a different rule kicking in, which sounds like your test methods look like this:
function test_something()
{
//
}
It’s missing a visibility modifier (i.e. public).
I think you might need to read up on PHP CodeSniffer a bit more and understand just what it is it’s actually doing.
If you try and write non-PSR-compliant code against a PSR style check then yes, you’re going to get lots of failures unless you configure phpcs to do the checks you want.
the premise that in tests the use of / ** @test * / is valid and extended to obviate the need to declare the scope of the method
That the method names in tests are underscore. Perhaps I do not know in depth if it is correct but if I know that it is commonly used by many programmers.
What I want is for phpcs to identify it as such.
After our talk, I found the solution and for that I am very grateful