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

Reference: https://www.drupal.org/core/beta-changes
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.

Comments

cilefen’s picture

Status: Active » Needs review
StatusFileSize
new2.47 KB

This is session_id in WebTestBase because I am wondering what it may break, if anything.

cilefen’s picture

$session_id is a bit of a pain because of $account->session_id.

tibbsa’s picture

Issue summary: View changes
StatusFileSize
new21.57 KB

Building on the above patch, this is more significant and will almost certainly break a ton things elsewhere. Locally, 'simpletest' tests were fine.

Status: Needs review » Needs work

The last submitted patch, 4: simpletest-cleanup-2382195-4.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new8.79 KB
new30.1 KB

Primarily root_user -> rootUser changes across the board

Status: Needs review » Needs work

The last submitted patch, 6: simpletest-cleanup-2382195-6.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new36.04 KB
new5.93 KB

Missed a few files in that last patch + langCode changes here.

tibbsa’s picture

The 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?

tibbsa’s picture

Issue summary: View changes
Status: Needs review » Needs work

The 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.

mile23’s picture

WebTestBase 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_auth and $http_credentials.

tibbsa’s picture

I 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?

mile23’s picture

Oops. Mistyped.

http://cgit.drupalcode.org/drupal/tree/core/modules/simpletest/src/WebTe...

  /**
   * HTTP authentication method.
   */
  protected $httpauth_method = CURLAUTH_BASIC;

  /**
   * HTTP authentication credentials (<username>:<password>).
   */
  protected $httpauth_credentials = NULL;
tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new2.72 KB
new38.19 KB

It 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.

Status: Needs review » Needs work

The last submitted patch, 15: clean_up_simpletest-2382195-15.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new38.92 KB

Rerolled.

diff --git a/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php b/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
index a616703..35bcf74 100644
--- a/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
@@ -62,7 +62,7 @@ public function testInstalled() {
     $this->assertUrl('user/1');
     $this->assertResponse(200);
     // Confirm that we are logged-in after installation.
-    $this->assertText($this->root_user->getUsername());
+    $this->assertText($this->rootUser->getUsername());
     // Confirm that the minimal profile was installed.
     $this->assertEqual(drupal_get_profile(), 'minimal');
   }
mile23’s picture

Status: Needs review » Reviewed & tested by the community

I think TestBase::run() is more for pulling in the settings, and then WebTestBase:: 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 to TestBase seems 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.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageForeignTest.php
@@ -19,7 +19,7 @@ class InstallerTranslationMultipleLanguageForeignTest extends InstallerTranslati
-  protected $langcode = 'de';
+  protected $langCode = 'de';

Here and elsewhere: This should not be changed. We refer to language codes as $langcode everywhere in code, not $lang_code. So by the same logic it should be $this->langcode not $this->langCode.

This is one of those cases where we ditch our own standards of not abbreviating. In theory it should be $language_code and $this->languageCode but we've decided that that's too many characters to type.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new3.79 KB
new35.38 KB

Status: Needs review » Needs work

The last submitted patch, 20: clean_up_simpletest-2382195-19.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new35.43 KB

Ah, new core commits came in between my pull and when I finished working on this. Rerolled.

mile23’s picture

Interestingly, 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.

mile23’s picture

Status: Needs review » Needs work
tadityar’s picture

Status: Needs work » Needs review
StatusFileSize
new35.42 KB

Erased the private_files_directory. There's just one occurrence of it :)

mile23’s picture

Status: Needs review » Reviewed & tested by the community

OK, 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.

langCode is nowhere to be found, and the refactoring of httpauth_* properties in #15 is still there, so we're happy.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: clean_up_simpletest-2382195-25.patch, failed testing.

subhojit777’s picture

Assigned: Unassigned » subhojit777
subhojit777’s picture

StatusFileSize
new36.05 KB
new646 bytes
subhojit777’s picture

Assigned: subhojit777 » Unassigned
Status: Needs work » Needs review
subhojit777’s picture

Status: Needs review » Needs work

The last submitted patch, 29: clean_up_simpletest-2382195-29.patch, failed testing.

mile23’s picture

The test failed due to being unable to apply the patch. The patch applies locally for me, so let's re-try the testbot.

rpayanm’s picture

Status: Needs work » Needs review
mile23’s picture

Status: Needs review » Reviewed & tested by the community

So re-ups on the RTBC from #26, plus refactoring NodeAccessViewGrantsCacheContextTest which was added in #2390691: Expose node grants as cache context.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 29: clean_up_simpletest-2382195-29.patch, failed testing.

tadityar’s picture

Status: Needs work » Needs review
StatusFileSize
new36.02 KB

Re-rolled

Status: Needs review » Needs work

The last submitted patch, 38: clean_up_simpletest-2382195-38.patch, failed testing.

Status: Needs work » Needs review
mile23’s picture

Status: Needs review » Reviewed & tested by the community

phpcs 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.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Looks like Alex has been committing others of these, so joining the club. :P

Committed and pushed to 8.0.x. Thanks!

  • webchick committed b45af92 on 8.0.x
    Issue #2382195 by tibbsa, subhojit777, tadityar, cilefen, Mile23: Clean-...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.