WebformElementManagedFileImageTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementManagedFileImageTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
use Drupal\Tests\TestFileCreationTrait;
use Drupal\webform\Entity\Webform;
class WebformElementManagedFileImageTest extends WebformElementManagedFileTestBase {
use TestFileCreationTrait;
public static $modules = [
'file',
'image',
'webform',
];
protected static $testWebforms = [
'test_element_image_file',
'test_element_image_file_attach',
];
public function testImageFileUpload() {
$this
->drupalLogin($this->rootUser);
$webform_image_file = Webform::load('test_element_image_file');
$images = $this
->getTestFiles('image');
$image = reset($images);
$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.');
$webform_image_file_attach = Webform::load('test_element_image_file_attach');
$sid = $this
->postSubmissionTest($webform_image_file_attach);
$this
->assertRaw("/system/files/styles/thumbnail/private/webform/test_element_image_file_attach/{$sid}/webform_image_file_attachment.gif");
}
}