Use constants when calling CommentTestBase::setCommentAnonymous

Created on 21 June 2023, 12 months ago
Updated 22 July 2023, 11 months ago

Problem/Motivation

Discovered whilst working on 🐛 [random test failure] Random failure in CommentStatisticsTest Fixed :

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

📌 Task
Status

Fixed

Version

10.1

Component
Comment 

Last updated 2 days ago

Created by

🇳🇱Netherlands Spokje

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024