You are here

protected function AjaxCommentsFunctionalTest::setUp in AJAX Comments 8

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/AjaxCommentsFunctionalTest.php, line 44

Class

AjaxCommentsFunctionalTest
Javascript functional tests for ajax comments.

Namespace

Drupal\Tests\ajax_comments\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->entityTypeManager = $this->container
    ->get('entity_type.manager');

  // Ensure an `article` node type exists.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);
  $this
    ->addDefaultCommentField('node', 'article');
  $comment_field = $this->entityTypeManager
    ->getStorage('field_config')
    ->load('node.article.comment');
  $comment_field
    ->setSetting('per_page', 10);
  $comment_field
    ->save();

  // Enable ajax comments on the comment field.
  $entity_view_display = EntityViewDisplay::load('node.article.default');
  $renderer = $entity_view_display
    ->getRenderer('comment');
  $renderer
    ->setThirdPartySetting('ajax_comments', 'enable_ajax_comments', '1');
  $entity_view_display
    ->save();
}