Verified Commit 4bfd55f3 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3368175 by Spokje: Minimize login as admin user to change settings in...

Issue #3368175 by Spokje: Minimize login as admin user to change settings in comment functional tests
parent d7a8c14f
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -133,10 +133,8 @@ public function testApprovalNodeInterface() {
      'post comments' => TRUE,
      'skip comment approval' => FALSE,
    ]);
    $this->drupalLogin($this->adminUser);
    // Ensure that doesn't require contact info.
    $this->setCommentAnonymous(CommentInterface::ANONYMOUS_MAYNOT_CONTACT);
    $this->drupalLogout();

    // Post anonymous comment without contact info.
    $subject = $this->randomMachineName();
@@ -219,10 +217,8 @@ public function testEditComment() {
    $this->drupalLogout();

    // Post anonymous comment.
    $this->drupalLogin($this->adminUser);
    // Ensure that we need email id before posting comment.
    $this->setCommentAnonymous(CommentInterface::ANONYMOUS_MUST_CONTACT);
    $this->drupalLogout();

    // Post comment with contact info (required).
    $author_name = $this->randomMachineName();
+0 −4
Original line number Diff line number Diff line
@@ -40,9 +40,7 @@ protected function setUp(): void {
   * Tests anonymous comment functionality.
   */
  public function testAnonymous() {
    $this->drupalLogin($this->adminUser);
    $this->setCommentAnonymous(CommentInterface::ANONYMOUS_MAYNOT_CONTACT);
    $this->drupalLogout();

    // Preview comments (with `skip comment approval` permission).
    $edit = [];
@@ -118,9 +116,7 @@ public function testAnonymous() {
    $this->assertSession()->pageTextContains('The name you used (' . $this->adminUser->getAccountName() . ') belongs to a registered user.');

    // Require contact info.
    $this->drupalLogin($this->adminUser);
    $this->setCommentAnonymous(CommentInterface::ANONYMOUS_MUST_CONTACT);
    $this->drupalLogout();

    // Try to post comment with contact info (required).
    $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
+0 −7
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ class CommentInterfaceTest extends CommentTestBase {
   */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->adminUser);
    // Make sure that comment field title is not displayed when there's no
    // comments posted.
    $this->drupalGet($this->node->toUrl());
@@ -39,7 +38,6 @@ protected function setUp(): void {
    $this->setCommentForm(TRUE);
    $this->setCommentSubject(FALSE);
    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
    $this->drupalLogout();
  }

  /**
@@ -63,10 +61,8 @@ public function testCommentInterface() {

    // Set comments to have subject and preview to required.
    $this->drupalLogout();
    $this->drupalLogin($this->adminUser);
    $this->setCommentSubject(TRUE);
    $this->setCommentPreview(DRUPAL_REQUIRED);
    $this->drupalLogout();

    // Create comment #2 that allows subject and requires preview.
    $this->drupalLogin($this->webUser);
@@ -208,9 +204,7 @@ public function testCommentInterface() {
    $this->assertFalse($this->commentExists($reply, TRUE), 'Reply not found.');

    // Enabled comment form on node page.
    $this->drupalLogin($this->adminUser);
    $this->setCommentForm(TRUE);
    $this->drupalLogout();

    // Submit comment through node form.
    $this->drupalLogin($this->webUser);
@@ -220,7 +214,6 @@ public function testCommentInterface() {

    // Disable comment form on node page.
    $this->drupalLogout();
    $this->drupalLogin($this->adminUser);
    $this->setCommentForm(FALSE);
  }

+0 −2
Original line number Diff line number Diff line
@@ -53,12 +53,10 @@ protected function setUp(): void {
   */
  public function testThreadedCommentView() {
    // Set comments to have subject required and preview disabled.
    $this->drupalLogin($this->adminUser);
    $this->setCommentPreview(DRUPAL_DISABLED);
    $this->setCommentForm(TRUE);
    $this->setCommentSubject(TRUE);
    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
    $this->drupalLogout();

    // Post comment.
    $this->drupalLogin($this->webUser);
+0 −6
Original line number Diff line number Diff line
@@ -35,13 +35,10 @@ class CommentPreviewTest extends CommentTestBase {
   * Tests comment preview.
   */
  public function testCommentPreview() {
    // As admin user, configure comment settings.
    $this->drupalLogin($this->adminUser);
    $this->setCommentPreview(DRUPAL_OPTIONAL);
    $this->setCommentForm(TRUE);
    $this->setCommentSubject(TRUE);
    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
    $this->drupalLogout();

    // Log in as web user.
    $this->drupalLogin($this->webUser);
@@ -94,13 +91,10 @@ public function testCommentPreview() {
   * Tests comment preview.
   */
  public function testCommentPreviewDuplicateSubmission() {
    // As admin user, configure comment settings.
    $this->drupalLogin($this->adminUser);
    $this->setCommentPreview(DRUPAL_OPTIONAL);
    $this->setCommentForm(TRUE);
    $this->setCommentSubject(TRUE);
    $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
    $this->drupalLogout();

    // Log in as web user.
    $this->drupalLogin($this->webUser);
Loading