You are here

public function WebformElementImageResolutionTest::testImageResolution in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Element/WebformElementImageResolutionTest.php \Drupal\Tests\webform\Functional\Element\WebformElementImageResolutionTest::testImageResolution()

Tests image resolution element.

File

tests/src/Functional/Element/WebformElementImageResolutionTest.php, line 22

Class

WebformElementImageResolutionTest
Tests for webform image resolution element.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testImageResolution() {
  $this
    ->drupalGet('/webform/test_element_image_resolution');

  // Check rendering.
  $this
    ->assertRaw('<label>webform_image_resolution_advanced</label>');
  $this
    ->assertRaw('<label for="edit-webform-image-resolution-advanced-x" class="visually-hidden">{width_title}</label>');
  $this
    ->assertRaw('<input data-drupal-selector="edit-webform-image-resolution-advanced-x" type="number" id="edit-webform-image-resolution-advanced-x" name="webform_image_resolution_advanced[x]" value="300" step="1" min="1" class="form-number" />');
  $this
    ->assertRaw('<label for="edit-webform-image-resolution-advanced-y" class="visually-hidden">{height_title}</label>');
  $this
    ->assertRaw('<input data-drupal-selector="edit-webform-image-resolution-advanced-y" type="number" id="edit-webform-image-resolution-advanced-y" name="webform_image_resolution_advanced[y]" value="400" step="1" min="1" class="form-number" />');
  $this
    ->assertRaw('{description}');

  // Check validation.
  $this
    ->drupalPostForm('/webform/test_element_image_resolution', [
    'webform_image_resolution[x]' => '100',
  ], 'Submit');
  $this
    ->assertRaw('Both a height and width value must be specified in the webform_image_resolution field.');

  // Check processing.
  $this
    ->drupalPostForm('/webform/test_element_image_resolution', [], 'Submit');
  $this
    ->assertRaw("webform_image_resolution: ''\nwebform_image_resolution_advanced: 300x400");
}