Verified Commit d35edb34 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439830 by thebumik, alexpott, pradhumanjain2311, vensires, smustgrave,...

Issue #3439830 by thebumik, alexpott, pradhumanjain2311, vensires, smustgrave, kristiaanvandeneynde, larowlan: Fix Comments tests that rely on UID1's super user behavior

(cherry picked from commit 2b0321c1)
parent 9e0c5a53
Loading
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -15,14 +15,6 @@
 */
class CommentStatisticsTest extends CommentTestBase {

  /**
   * {@inheritdoc}
   *
   * @todo Remove and fix test to not rely on super user.
   * @see https://www.drupal.org/project/drupal/issues/3437620
   */
  protected bool $usesSuperUserAccessPolicy = TRUE;

  /**
   * A secondary user for posting comments.
   *
@@ -41,12 +33,17 @@ class CommentStatisticsTest extends CommentTestBase {
  protected function setUp(): void {
    parent::setUp();

    // Add more permissions the admin user.
    $this->adminUser->addRole($this->drupalCreateRole([
      'administer permissions',
      'access administration pages',
      'administer site configuration',
    ]))->save();
    // Create a second user to post comments.
    $this->webUser2 = $this->drupalCreateUser([
      'post comments',
      'create article content',
      'edit own comments',
      'post comments',
      'skip comment approval',
      'access comments',
      'access content',
@@ -88,7 +85,8 @@ public function testCommentNodeCommentStatistics() {
    // Prepare for anonymous comment submission (comment approval enabled).
    // Note we don't use user_role_change_permissions(), because that caused
    // random test failures.
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->adminUser);

    $this->drupalGet('admin/people/permissions');
    $edit = [
      'anonymous[access comments]' => 1,
@@ -117,7 +115,7 @@ public function testCommentNodeCommentStatistics() {
    // Prepare for anonymous comment submission (no approval required).
    // Note we don't use user_role_change_permissions(), because that caused
    // random test failures.
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/people/permissions');
    $edit = [
      'anonymous[skip comment approval]' => 1,