You are here

public function CommentAlterNodeReferenceTest::testEntityReferenceFieldSingle in Comment Alter 8

Tests for single valued node reference field comment altering.

File

tests/src/Functional/CommentAlterNodeReferenceTest.php, line 62

Class

CommentAlterNodeReferenceTest
Tests the comment alter module functions for node reference fields.

Namespace

Drupal\Tests\comment_alter\Functional

Code

public function testEntityReferenceFieldSingle() {
  $field_name = $this
    ->addNodeReferenceField(1);
  $this
    ->createEntityObject();
  $new_node = $this
    ->randomMachineName();
  $this
    ->postComment([
    "comment_alter_fields[{$field_name}][0][target_id]" => $new_node,
  ]);
  $this
    ->assertCommentDiff([
    $field_name => [
      [
        NULL,
        $new_node,
      ],
    ],
  ]);
  $this
    ->assertCommentSettings($field_name);
  $this
    ->assertRevisionDelete();
  $this
    ->assertAlterableField($field_name);
}