The search module uses Test class members with underscored names. Some examples are big_user, web_user and admin_user, but there could be others. According to our coding conventions, these should be renamed to bigUser, webUser and adminUser. In addition, some properties are undefined but should be.
See the parent issue #1811638: [meta] Clean-up Test members - ensure property definition and use of camelCase naming convention.
Beta phase evaluation
| Issue category | Task, because this is a coding standards change. |
|---|---|
| Issue priority | Not critical because coding standard changes are not critical. |
| Unfrozen changes | Unfrozen because it only changes automated tests. |
| Disruption | There is no disruption expected from this sort of change. |
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | clean_up_search_module-2380429-27.patch | 35.63 KB | tibbsa |
Comments
Comment #1
markat commentedComment #2
pwolanin commentedsimple cleanup
Comment #3
cilefen commentedComment #4
alexpottWhat about
$this->admin_roleand$this->comment_subject? These should also be defined.Comment #5
cilefen commentedComment #6
cilefen commentedComment #7
cilefen commentedThere are more instances in many files that need fixing.
Comment #8
hussainwebComment #9
tibbsa commentedGood job. There are still some areas that need more fine-tuning though.
SearchCommentCountToggleTest.php
This isn't just an 'object' -- it should be a \Drupal\user\UserInterface.
SearchCommentTest.php (testSearchResultsCommentAccess())
$this->commentSubject and $this->adminRole are used without prior declaration.
Below are some other examples of properties being used without prior declaration (my proposed patch in #2383287: Add warning about use of undeclared class properties in test classes is helpful in spotting these, since you can run the tests locally to flag these).
(Note that many of these properties need not only a declaration but a rename to camelCase convention.)
Comment #10
hussainwebChanges as per #9.
Comment #11
jhodgdonThanks! I haven't checked to see if there are other variables needing declaration, but what is in this patch looks mostly good.
A few items to fix that I noticed:
a) SearchCountToggleTest
It is preferable to use @var \Drupal\something\something[] rather than @var array, because it is more specific and helps IDE users.
Also same problem in SearchLanguageTest, SearchMultilingualEntityTest, etc.
b) SearchCommentTest
"Id" is a psychological term. This should be "ID", which means identifier.
c) Hopefully not out of scope for this issue:
This doc block could use a @var line (looks like it's an int).
d) SearchNodePunctuationTest
This one is still @var object instead of the class/interface. SearchPageCacheTagsTest too, same variable, and SearchPageOverrideTest, and several other classes.
Also probably "permissions" should be "permission"? Your patch has "permissions" in several places but "permission" in most; permission is better.
e)
Looks like $numbers and $nodes need doc blocks? Same in SearchNumbersTest.
Comment #12
mile23Patch still applies.
Comment #13
tibbsa commentedThis should resolve some more of the things from #11.
One potentially controversial suggested change arises in the number tests. Having moved the explanation of what the variable was to the class definition, which wouldn't be duplicated in the setUp() function body, it seemed to make sense to also move the list of numbers to be tested to be a part of the declaration itself (given that they are "set and never changed" anywhere else). That is not strictly a coding standards issue though.
Comment #14
tibbsa commentedComment #15
jhodgdonLooks better! I think your changes in the Numbers tests make sense.
I only found one small thing to fix, in SearchEmbedFormTest:
In @var we use "int" not "integer". See https://www.drupal.org/node/1354#types
The rest looks great, thanks!
I also looked through all of the Search tests to see if there were any other things that should be fixed in this way, and I think it's all good now.
Although I did notice that SearchMatchTest has some const declarations in the global scope at the top of the file, that should probably be class members, and which do not have doc blocks:
I'm not sure if that is in scope for this issue or if we should file a separate issue? These could be documented as:
or something like that.
Comment #16
mile23I'd say the constants are out of scope for this issue.
The @var part would be, too, but it's already in the patch.
Comment #17
jhodgdonFair enough. Here's a new patch with the @var int changed to @var integer, which I did by editing the -13 patch file. It should be RTBC now.
Comment #18
mile23Patch doesn't miss any under_score class properties, and passes tests, so RTBC +1.
Comment #20
jhodgdonComment #21
tibbsa commentedRolling.
Comment #22
tibbsa commentedReroll, nothing fancy.
Comment #24
tibbsa commentedEvidently there was an API change on UserInterface::getRoles() in HEAD and I missed the added parameter during the re-roll. This should work now.
Comment #25
mile23phpcs gives you a green light, bringing back the RTBC.
Comment #26
tstoecklerThis should be "node" not "ndoe". Also while we're at it, let's add a blank line before the variable declaration.
Comment #27
tibbsa commentedComment #28
mile23The patch in #27 applies, changes relevant underscore to camelCase, and does not contain the 'ndoe' typo. :-)
Comment #30
tibbsa commentedTests green locally against HEAD. Suspect Testbot brain fart. Will re-queue for testing in a little while once it hopefully gets past its hiccups.
Comment #32
tibbsa commentedAll good, back to RTBC.
Comment #33
tibbsa commentedComment #34
mile23RTBC+1.
Comment #35
tibbsa commentedComment #36
alexpottCommitted 1241586 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation for to the issue summary.