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

Note: The RDF module has one test which derives from CommentTestBase which is changed in these patches. That test has been corrected to work with the revised CommentTestBase in this patch. No other changes were made in the RDF module in this issue. See #2381921: Clean-up RDF module test members - ensure property definition and use of camelCase naming convention

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 expected from this sort of change.

Comments

cilefen’s picture

Issue summary: View changes
tibbsa’s picture

Status: Active » Needs review
StatusFileSize
new41.17 KB

Changed CommentTestBase::web_user -> webUser; CommentTestBase::admin_user -> adminUser

Does not alter internal, intra-function variable naming conventions.

Status: Needs review » Needs work

The last submitted patch, 2: comment-testing-camelcase-2380023-D8-1.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new39.57 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 4: comment-testing-camelcase-2380023-D8-4.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new42.9 KB
tibbsa’s picture

Assigned: tibbsa » Unassigned

Looks complete now.

cilefen’s picture

@tibbsa: See the update to the parent issue.

cilefen’s picture

Issue summary: View changes
tibbsa’s picture

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

I will check on this.

tibbsa’s picture

Title: Clean-up Comment module test members to use camelCase naming convention » Clean-up Comment module Test members - ensure property definition and use of camelCase naming convention
tibbsa’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new40.91 KB
new1.97 KB

Corrections for undefined properties and, in one instance, a doubly-defined adminUser. Note that CommentTestBase provides webUser and adminUser already, and so tests derived from CommentTestBase already include these properties.

cilefen’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/comment/src/Tests/CommentStatisticsTest.php
    @@ -16,12 +16,18 @@
    +   * A secnodary user for posting of comments. ¶
    

    There is a whitespace error and a mistype here. I would prefer 'A secondary user for posting comments.'.

  2. +++ b/core/modules/comment/src/Tests/CommentTypeTest.php
    @@ -21,29 +21,10 @@
    -   * Admin user
    -   *
    -   * @var \Drupal\Core\Session\AccountInterface
    -   */
    -  protected $adminUser;
    -
    -  /**
    -   * Permissions to grant admin user.
    -   *
    -   * @var array
    -   */
    -  protected $permissions = array(
    -    'administer comments',
    -    'administer comment fields',
    -    'administer comment types',
    -  );
    -
    -  /**
    

    This adminUser is configured with different permissions than in the parent class, so I would not remove the overridden property in this class.

I found some more to be changed:

$ egrep -r '\$this\->[a-z]+_[a-z_]+' core/modules/comment/src/Tests/
core/modules/comment/src/Tests//Views/ArgumentUserUIDTest.php:        'nid' => $this->node_user_posted->id(),
core/modules/comment/src/Tests//Views/ArgumentUserUIDTest.php:        'nid' => $this->node_user_commented->id(),
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:    $this->comment_titles = array(
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:      'entity_id' => $this->node_user_commented->id(),
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:    $this->comment->subject->value = $this->comment_titles['en'];
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:    $this->comment->comment_body->value = $this->comment_titles['en'];
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:      $translation->comment_body->value = $this->comment_titles[$langcode];
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:      $translation->subject->value = $this->comment_titles[$langcode];
core/modules/comment/src/Tests//Views/CommentFieldFilterTest.php:      $this->assertEqual(substr_count($text, $this->comment_titles[$langcode]), 2 * $count, 'Translation ' . $langcode . ' has count ' . $count . ' with ' . $message);
core/modules/comment/src/Tests//Views/CommentTestBase.php:    $this->node_user_posted = $this->drupalCreateNode();
core/modules/comment/src/Tests//Views/CommentTestBase.php:    $this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->id()));
core/modules/comment/src/Tests//Views/CommentTestBase.php:      'entity_id' => $this->node_user_commented->id(),
core/modules/comment/src/Tests//Views/FilterUserUIDTest.php:        'nid' => $this->node_user_posted->id(),
core/modules/comment/src/Tests//Views/FilterUserUIDTest.php:        'nid' => $this->node_user_commented->id(),
core/modules/comment/src/Tests//Views/FilterUserUIDTest.php:    $this->column_map = array('nid' => 'nid');
core/modules/comment/src/Tests//Views/FilterUserUIDTest.php:    $this->assertIdenticalResultset($view, $result_set, $this->column_map);

The last submitted patch, 12: comment-testing-camelcase-2380023-D8-12.patch, failed testing.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new46.67 KB
new7.54 KB

With respect to the reference to $this->column_map in FilterUserUIDTest where I simply removed the reference to $this->, that seems to be consistent with other tests (e.g. in ArgumentUserUIDTest and in several Views-specific tests). In other words, there seems to be no reason for this to be a class property in the first place.

Status: Needs review » Needs work

The last submitted patch, 15: comment-testing-camelcase-2380023-D8-15.patch, failed testing.

cilefen’s picture

It looks like CommentAttributesTest extends CommentTestBase, so you have to include that in this patch.

tibbsa’s picture

Status: Needs work » Needs review
StatusFileSize
new54.55 KB
new7.88 KB
cilefen’s picture

  1. +++ b/core/modules/comment/src/Tests/CommentTypeTest.php
    @@ -19,7 +19,6 @@
    -
    

    There is usually a space after the class declaration, so don't remove it.

  2. +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
    @@ -27,7 +27,37 @@
    +   * A normal user (who can be the author of a node that $account will
    +   * comment upon).
    

    This comment must be on a single line. A full description can come after a full space.

  3. +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
    @@ -27,7 +27,37 @@
    +   * Stores a node posted by the user created as $account;
    

    The comment must end with a period, not a semicolon.

  4. +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
    @@ -27,7 +27,37 @@
    +   * Stores a node posted by the user created as $account2, upon which
    +   * the user created as $account will comment.
    

    Same thing - must be one line.

  5. +++ b/core/modules/rdf/src/Tests/CommentAttributesTest.php
    @@ -19,6 +19,20 @@
    +   * URI of the test node created by CommentTestBase::setUp()
    

    This must end with a period.

tibbsa’s picture

@cilefen: Thank you for the assistance. I will rework those.

tibbsa’s picture

No code changes here -- just docblock updates.

cilefen’s picture

Status: Needs review » Needs work

@tibbsa: Again, great work.

Please do not change anything in the RDF file that is not strictly necessary so we can keep this issue in scope. I think all that is needed is webUser(?). Could you please update this issue summary and #2381921: Clean-up RDF module test members - ensure property definition and use of camelCase naming convention accordingly?

tibbsa’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new50.09 KB
new5.87 KB

This is a revision of the patch in #22 to roll back all but the ->webUser changes on the RDF module.

Status: Needs review » Needs work

The last submitted patch, 24: comment-testing-camelcase-2380023-D8-24.patch, failed testing.

subhojit777’s picture

Assigned: Unassigned » subhojit777
Issue tags: +Needs reroll
subhojit777’s picture

Assigned: subhojit777 » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new50.13 KB
subhojit777’s picture

+++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
@@ -24,7 +24,14 @@ class CommentTranslationUITest extends ContentTranslationUITest {
   /**
-   * Modules to install.
+   * An administrative user with permission to administer comments.
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $adminUser;
+
+  /**
+   * Modules to enable.
    *
    * @var array
    */
@@ -143,8 +150,8 @@ protected function assertPublishedStatus() {

@@ -143,8 +150,8 @@ protected function assertPublishedStatus() {
    * Tests translate link on comment content admin page.
    */
   function testTranslateLinkCommentAdminPage() {
-    $this->admin_user = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer comments', 'skip comment approval')));
-    $this->drupalLogin($this->admin_user);
+    $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer comments', 'skip comment approval')));
+    $this->drupalLogin($this->adminUser);

This changes were introduced during reroll

tibbsa’s picture

Looks good to me.

mile23’s picture

Status: Needs review » Needs work

CommentCSSTest line 131 missed a camelCase:

        $expectedJS = ($case['user'] !== 'anonymous');
        $this->assertIdentical($expectedJS, isset($settings['ajaxPageState']['js']['core/modules/comment/js/comment-new-indicator.js']), 'drupal.comment-new-indicator library is present.');

CommentTranslationUITest line 24: No @var declaration.

cilefen’s picture

$expectedJS is not a class property, so no need to camelCase it.

mile23’s picture

Yes, exactly. :-) It should be $expected_js.

cilefen’s picture

Oh .. ha ha. That's correct. It's a little out-of-scope but we could fix it.

tibbsa’s picture

Oh, now your comment in the other issue makes sense... OK, these issues were primarily concerned with fixing the class-level properties, given that people sometimes derive new tests from existing tests and undeclared, undefined inherited properties could be an issue. Intra-function issues and coding conventions were not really in scope for all of these changes (since they're unlikely to cause any fragility overall), but I suppose this could be fixed. But I wouldn't go back and do a whole bunch more work on all the other modules for it?

Status: Needs work » Needs review
mile23’s picture

In that case.... Will RTBC if it passes green. :-)

mile23’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #28 refactors class-level properties from under_score to camelCase as the coding standards demand.

I know this because I applied the patch, ran my own coding standards review with netbeansdrupalcomposed, and poked through all the test classes to find camel case and underscore violations. I found a few that were mentioned in #31, but those are apparently out of scope for this issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
git ac https://www.drupal.org/files/issues/clean_up_comment_module-2380023-28.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 51330  100 51330    0     0   127k      0 --:--:-- --:--:-- --:--:--  129k
error: patch failed: core/modules/rdf/src/Tests/CommentAttributesTest.php:105
error: core/modules/rdf/src/Tests/CommentAttributesTest.php: patch does not apply

That is not in commnet module.

cilefen’s picture

@alexpott: RDF CommentAttributesTest extends CommentTestBase

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 28: clean_up_comment_module-2380023-28.patch, failed testing.

rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new50.12 KB

rerolled from #28

mile23’s picture

Status: Needs review » Reviewed & tested by the community

Re-up my RTBC from #28.

As noted above, this patch touches more than the comment module because other modules use comment's test base classes.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/comment/src/Tests/CommentStatisticsTest.php
    @@ -16,12 +16,18 @@
     class CommentStatisticsTest extends CommentTestBase {
    +  /**
    

    Let's add a blank newline in between here.

  2. +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php
    @@ -24,7 +24,14 @@ class CommentTranslationUITest extends ContentTranslationUITest {
    +   * Modules to enable.
    

    This should be "install".

subhojit777’s picture

Assigned: Unassigned » subhojit777
subhojit777’s picture

Assigned: subhojit777 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new50.08 KB
new938 bytes
mile23’s picture

Status: Needs review » Reviewed & tested by the community

Still applies, phpcs still tells me there are no underscore problems, and pulls in the changes from #45.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 09b496e and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation for to the issue summary.

  • alexpott committed 09b496e on 8.0.x
    Issue #2380023 by tibbsa, subhojit777, rpayanm: Clean-up Comment module...

Status: Fixed » Closed (fixed)

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