Problem/Motivation

Discovered whilst working on #2980750: [random test failure] Random failure in CommentStatisticsTest:

There are quite a few tests in the comment module that call \Drupal\Tests\comment\Functional\CommentTestBase::setCommentAnonymous passing integers as the argument.

Let's use the already defined CONSTANTs in \Drupal\comment\CommentInterface:

  /**
   * Anonymous posters cannot enter their contact information.
   */
  const ANONYMOUS_MAYNOT_CONTACT = 0;

  /**
   * Anonymous posters may leave their contact information.
   */
  const ANONYMOUS_MAY_CONTACT = 1;

  /**
   * Anonymous posters are required to leave their contact information.
   */
  const ANONYMOUS_MUST_CONTACT = 2;

Steps to reproduce

Do a search/grep on $this->setCommentAnonymous( and see (quite) a being called with integers as argument.

NOTE: There's one occurence of $this->setCommentAnonymous(TRUE); in \Drupal\Tests\comment\Functional\CommentLinksTest::testCommentLinks, which would "translate" to $this->setCommentAnonymous(CommentInterface::ANONYMOUS_MAY_CONTACT);.

As it turns out this isn't needed in that test that line is removed in this issue.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3368145

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Spokje created an issue. See original summary.

spokje’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Seems like a simple change that didn't break anything.

  • longwave committed 83da1db4 on 10.1.x
    Issue #3368145 by Spokje: Use constants when calling CommentTestBase::...

  • longwave committed b9d2e855 on 11.x
    Issue #3368145 by Spokje: Use constants when calling CommentTestBase::...
longwave’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: +ddd2023

Backported to 10.1.x as a tests-only fix.

Committed and pushed b9d2e85583 to 11.x and 83da1db419 to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

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