You are here

public function CommentAlterImageTest::testImageFieldSingle in Comment Alter 8

Tests for single valued image field comment altering.

File

tests/src/Functional/CommentAlterImageTest.php, line 77

Class

CommentAlterImageTest
Tests the comment alter module functions for image fields.

Namespace

Drupal\Tests\comment_alter\Functional

Code

public function testImageFieldSingle() {
  $field_name = $this
    ->addImageField(1);
  $this
    ->createEntityObject();
  $image = current($this
    ->getImageFiles());
  $this
    ->postCommentWithImage($field_name, [
    'files[comment_alter_fields_' . $field_name . '_0]' => drupal_realpath($image->uri),
  ]);
  $this
    ->assertCommentDiff([
    $field_name => [
      [
        NULL,
        'Image: ' . $image->filename,
      ],
      [
        NULL,
        'File ID: 1',
      ],
    ],
  ]);
  $this
    ->assertRevisionDelete();
}