You are here

CommentOperationsTest.php in Drupal 10

File

core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php
View source
<?php

namespace Drupal\Tests\comment\Functional\Views;


/**
 * Tests comment operations.
 *
 * @group comment
 */
class CommentOperationsTest extends CommentTestBase {

  /**
   * Views used by this test.
   *
   * @var array
   */
  public static $testViews = [
    'test_comment_operations',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * Tests the operations field plugin.
   */
  public function testCommentOperations() {
    $admin_account = $this
      ->drupalCreateUser([
      'administer comments',
    ]);
    $this
      ->drupalLogin($admin_account);
    $this
      ->drupalGet('test-comment-operations');
    $this
      ->assertSession()
      ->statusCodeEquals(200);

    // Assert Edit operation is present.
    $this
      ->assertSession()
      ->elementsCount('xpath', '//td[contains(@class, "views-field-operations")]//li/a[text() = "Edit"]', 1);

    // Assert Delete operation is present.
    $this
      ->assertSession()
      ->elementsCount('xpath', '//td[contains(@class, "views-field-operations")]//li/a[text() = "Delete"]', 1);
  }

}

Classes

Namesort descending Description
CommentOperationsTest Tests comment operations.