The simpletest 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.
Two new issues were created that take some of the scope of this issue away:
- #2388181: Clean-up WebTestBase test members - ensure property definition and use of camelCase naming convention
- #2388071: Clean-up TestBase test members - ensure property definition and use of camelCase naming convention
As such, the patches below (most recent at #8) should be ignored and this issue reconsidered once the above two are into core.
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 (except to automated tests) expected from this sort of change. |
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | clean_up_simpletest-2382195-38.patch | 36.02 KB | tadityar |
| #29 | clean_up_simpletest-2382195-29.patch | 36.05 KB | subhojit777 |
| #22 | clean_up_simpletest-2382195-22.patch | 35.43 KB | tibbsa |
Comments
Comment #1
rpayanmComment #2
cilefen commentedThis is session_id in WebTestBase because I am wondering what it may break, if anything.
Comment #3
cilefen commented$session_id is a bit of a pain because of $account->session_id.
Comment #4
tibbsa commentedBuilding on the above patch, this is more significant and will almost certainly break a ton things elsewhere. Locally, 'simpletest' tests were fine.
Comment #6
tibbsa commentedPrimarily root_user -> rootUser changes across the board
Comment #8
tibbsa commentedMissed a few files in that last patch + langCode changes here.
Comment #9
mile23Added separate issues for WebTestBase and TestBase:
Comment #10
tibbsa commentedThe sub-issues for this were created on a per-module basis, not a per-class basis. Why separate these two? You could re-factor the above patch into two separate ones but why?
Comment #11
tibbsa commentedThe TestBase/WebTestBase issues are duplicative of some of what was in the patches above. Those two should be resolved first and then we can come back to fixing anything left in SimpleTest itself.
Comment #12
mile23WebTestBase and TestBase aren't tests, so I thought the tests *for the module* would be separate. Because I was horribly confused or something. I guess. Sorry.
I'll mark the class issues as closed won't fix.
Anyway, here's my review of the patch in #8:
WebTestBase still has
$http_authand$http_credentials.Comment #13
tibbsa commentedI took the simpletest module to be a bit of an exception to the rule, given that all/most of the relevant Test* classes are derived from WebTestBase/TestBase, but your logic was not unreasonable either!
Where are you seeing those variables?
..drupal $ egrep -rl '\->http_auth' *
..drupal $ egrep -rl '\->http_cred' *
I can't find either one anywhere in the Drupal codebase?
Comment #14
mile23Oops. Mistyped.
http://cgit.drupalcode.org/drupal/tree/core/modules/simpletest/src/WebTe...
Comment #15
tibbsa commentedIt turns out that those httpauth_* variables are actually initialized in TestBase::run(), and so need to be declared there rather than in WebTestBase. This is of course rather backward: TestBase has no use for this information. I can't quite fathom why these settings would not just be retrieved in WebTestBase::curlInitialize(), rather than being set up as class properties in TestBase::run(), but that's beyond the scope of this change.
Comment #17
tibbsa commentedRerolled.
Comment #18
mile23I think
TestBase::run()is more for pulling in the settings, and thenWebTestBase:: curlInitialize()can act on the settings. I'd bet it works this way because the ideal is to only generate the settings object once. It could probably use some refactor love, maybe.But I agree, it's out of scope for this issue to change things up too much, and moving the
$httpauth*properties toTestBaseseems like the right thing to do.Plus, this patch accomplishes the goal of changing all the properties in all the tests and other test base classes to make sure they have camelCase property names instead of under_score.
I know this because I did a bit of analysis with phpcs and couldn't find any instances of errors for that coding standard in the tests.
Therefore... RTBC.
Comment #19
tstoecklerHere and elsewhere: This should not be changed. We refer to language codes as
$langcodeeverywhere in code, not$lang_code. So by the same logic it should be$this->langcodenot$this->langCode.This is one of those cases where we ditch our own standards of not abbreviating. In theory it should be
$language_codeand$this->languageCodebut we've decided that that's too many characters to type.Comment #20
tibbsa commentedComment #22
tibbsa commentedAh, new core commits came in between my pull and when I finished working on this. Rerolled.
Comment #23
mile23Interestingly, after I applied this patch, TestBase has both ::privateFilesDirectory and ::private_files_directory.
Could be related to this: https://www.drupal.org/node/2392959
Probably needs a re-roll.
Comment #24
mile23Comment #25
tadityar commentedErased the private_files_directory. There's just one occurrence of it :)
Comment #26
mile23OK, so the patch in #25 seems to have dealt with the duplicate private files directory issue.
The patch applies, passes tests, and fixes the underscore property names issue according to
phpcs.langCodeis nowhere to be found, and the refactoring ofhttpauth_*properties in #15 is still there, so we're happy.Comment #28
subhojit777Comment #29
subhojit777Comment #30
subhojit777Comment #31
subhojit777Comment #33
mile23The test failed due to being unable to apply the patch. The patch applies locally for me, so let's re-try the testbot.
Comment #35
rpayanmComment #36
mile23So re-ups on the RTBC from #26, plus refactoring
NodeAccessViewGrantsCacheContextTestwhich was added in #2390691: Expose node grants as cache context.Comment #38
tadityar commentedRe-rolled
Comment #41
mile23phpcs says no camel case errors in test classes, which in the case of simpletest module is really all classes.
Previous RTBC before reroll in #36.
Comment #42
webchickLooks like Alex has been committing others of these, so joining the club. :P
Committed and pushed to 8.0.x. Thanks!