You are here

public function WebformElementManagedFileImageTest::testImageFileUpload in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Functional/Element/WebformElementManagedFileImageTest.php \Drupal\Tests\webform\Functional\Element\WebformElementManagedFileImageTest::testImageFileUpload()

Test image file upload.

File

tests/src/Functional/Element/WebformElementManagedFileImageTest.php, line 34

Class

WebformElementManagedFileImageTest
Test for webform element managed file image handling.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testImageFileUpload() {
  $this
    ->drupalLogin($this->rootUser);
  $webform_image_file = Webform::load('test_element_image_file');

  // Get test image.
  $images = $this
    ->getTestFiles('image');
  $image = reset($images);

  // Check image max resolution validation is being applied.
  $edit = [
    'files[webform_image_file_advanced]' => \Drupal::service('file_system')
      ->realpath($image->uri),
  ];
  $this
    ->postSubmission($webform_image_file, $edit);
  $this
    ->assertRaw('The image was resized to fit within the maximum allowed dimensions of <em class="placeholder">20x20</em> pixels.');

  // Get test image attachment.
  $webform_image_file_attach = Webform::load('test_element_image_file_attach');
  $sid = $this
    ->postSubmissionTest($webform_image_file_attach);

  // Check that thumbnail image style is used for the attachment.
  $this
    ->assertRaw("/system/files/styles/thumbnail/private/webform/test_element_image_file_attach/{$sid}/webform_image_file_attachment.gif");
}