Commit 1004c40d authored by catch's avatar catch
Browse files

Issue #3376369 by Spokje, quietone, smustgrave, catch: Remove use of book in...

Issue #3376369 by Spokje, quietone, smustgrave, catch: Remove use of book in non profile and update tests

(cherry picked from commit 2c6bb82a)
parent c0bfe53b
Loading
Loading
Loading
Loading
Loading
+0 −63
Original line number Diff line number Diff line
@@ -193,67 +193,4 @@ public function testCommentFieldCreate() {
    $this->assertSession()->statusMessageContains('Saved User comment configuration.', 'status');
  }

  /**
   * Tests that comment module works when installed after a content module.
   */
  public function testCommentInstallAfterContentModule() {
    // Create a user to do module administration.
    $this->adminUser = $this->drupalCreateUser([
      'access administration pages',
      'administer modules',
    ]);
    $this->drupalLogin($this->adminUser);

    // Drop default comment field added in CommentTestBase::setUp().
    FieldStorageConfig::loadByName('node', 'comment')->delete();
    if ($field_storage = FieldStorageConfig::loadByName('node', 'comment_forum')) {
      $field_storage->delete();
    }

    // Purge field data now to allow comment module to be uninstalled once the
    // field has been deleted.
    field_purge_batch(10);

    // Uninstall the comment module.
    $edit = [];
    $edit['uninstall[comment]'] = TRUE;
    $this->drupalGet('admin/modules/uninstall');
    $this->submitForm($edit, 'Uninstall');
    $this->submitForm([], 'Uninstall');
    $this->rebuildContainer();
    $this->assertFalse($this->container->get('module_handler')->moduleExists('comment'), 'Comment module uninstalled.');

    // Install core content type module (book).
    $edit = [];
    $edit['modules[book][enable]'] = 'book';
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');

    // Now install the comment module.
    $edit = [];
    $edit['modules[comment][enable]'] = 'comment';
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    $this->rebuildContainer();
    $this->assertTrue($this->container->get('module_handler')->moduleExists('comment'), 'Comment module enabled.');

    // Create nodes of each type.
    $this->addDefaultCommentField('node', 'book');
    $book_node = $this->drupalCreateNode(['type' => 'book']);

    $this->drupalLogout();

    // Try to post a comment on each node. A failure will be triggered if the
    // comment body is missing on one of these forms, due to postComment()
    // asserting that the body is actually posted correctly.
    $this->webUser = $this->drupalCreateUser([
      'access content',
      'access comments',
      'post comments',
      'skip comment approval',
    ]);
    $this->drupalLogin($this->webUser);
    $this->postComment($book_node, $this->randomMachineName(), $this->randomMachineName());
  }

}