You are here

public function CommentAlterTextTest::testTextFieldSingle in Comment Alter 8

Tests for single valued text field comment altering.

File

tests/src/Functional/CommentAlterTextTest.php, line 37

Class

CommentAlterTextTest
Tests the comment alter module functions for text fields.

Namespace

Drupal\Tests\comment_alter\Functional

Code

public function testTextFieldSingle() {
  $field_name = $this
    ->addTextField(1);

  // Create two random values of different length so that they may never be
  // equal.
  $old_value = $this
    ->randomMachineName(5);
  $new_value = $this
    ->randomMachineName(6);
  $this
    ->createEntityObject([
    $field_name => [
      'value' => $old_value,
    ],
  ]);
  $this
    ->assertAlterableField($field_name);
  $this
    ->postComment([
    "comment_alter_fields[{$field_name}][0][value]" => $new_value,
  ]);
  $this
    ->assertCommentDiff([
    $field_name => [
      [
        $old_value,
        $new_value,
      ],
    ],
  ]);
  $this
    ->assertCommentSettings($field_name);
  $this
    ->assertRevisionDelete();
}