function CommentTestBase::setCommentAnonymous

Same name and namespace in other branches
  1. 8.9.x core/modules/comment/src/Tests/CommentTestBase.php \Drupal\comment\Tests\CommentTestBase::setCommentAnonymous()
  2. 11.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentAnonymous()
  3. 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentAnonymous()
  4. 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentAnonymous()
  5. 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentAnonymous()

Sets the value governing restrictions on anonymous comments.

Parameters

\Drupal\comment\AnonymousContact|int $level: The level of the contact information allowed for anonymous comments.

7 calls to CommentTestBase::setCommentAnonymous()
CommentAdminTest::testApprovalAdminInterface in core/modules/comment/tests/src/Functional/CommentAdminTest.php
Tests comment approval functionality through admin/content/comment.
CommentAdminTest::testApprovalAdminInterface in core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php
Tests comment approval functionality through admin/content/comment.
CommentAdminTest::testApprovalNodeInterface in core/modules/comment/tests/src/Functional/CommentAdminTest.php
Tests comment approval functionality through the node interface.
CommentAdminTest::testCommentedTranslationDeletion in core/modules/comment/tests/src/Functional/CommentAdminTest.php
Tests commented translation deletion admin view.
CommentAdminTest::testEditComment in core/modules/comment/tests/src/Functional/CommentAdminTest.php
Tests editing a comment as an admin.

... See full list

File

core/modules/comment/tests/src/Functional/CommentTestBase.php, line 297

Class

CommentTestBase
Provides setup and helper methods for comment tests.

Namespace

Drupal\Tests\comment\Functional

Code

protected function setCommentAnonymous(AnonymousContact|int $level) {
  if (!$level instanceof AnonymousContact) {
    @trigger_error('Calling ' . __METHOD__ . ' with an integer $level parameter is deprecated in drupal:11.4.0 and it will be removed in drupal:13.0.0. Use the \\Drupal\\comment\\AnonymousContact enum instead. See https://www.drupal.org/node/3547352', E_USER_DEPRECATED);
    $level = AnonymousContact::from($level);
  }
  $this->setCommentSettings('anonymous', $level->value, new FormattableMarkup('Anonymous commenting set to level @level.', [
    '@level' => $level->value,
  ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.