You are here

public function CommentAlterListStringTest::testOptionsSelectMultiple in Comment Alter 8

Tests for multi-valued List (string) fields comment altering.

File

tests/src/Functional/CommentAlterListStringTest.php, line 66

Class

CommentAlterListStringTest
Tests the comment alter module functions for List (string) fields.

Namespace

Drupal\Tests\comment_alter\Functional

Code

public function testOptionsSelectMultiple() {
  $field_name = $this
    ->addOptionField('options_select', -1);
  $this
    ->createEntityObject([
    $field_name => [
      0 => [
        'value' => 1,
      ],
    ],
  ]);
  $this
    ->assertAlterableField($field_name);

  // The alterable fields on comment form have a wrapper of alterable_fields
  // over them because of the #parent property specified in the
  // comment_form_alter.
  $this
    ->postComment([
    "comment_alter_fields[{$field_name}][]" => [
      1,
      2,
    ],
  ]);
  $this
    ->assertCommentDiff([
    $field_name => [
      [
        1,
        1,
      ],
      [
        NULL,
        2,
      ],
    ],
  ]);
  $this
    ->assertCommentSettings($field_name);
  $this
    ->assertRevisionDelete();
}