You are here

public function ImageEffectsTest::testEffectFormValidationErrors in Drupal 8

Tests if validation errors are passed plugin form to the parent form.

File

core/modules/image/tests/src/Functional/ImageEffectsTest.php, line 195

Class

ImageEffectsTest
Tests that the image effects pass parameters to the toolkit correctly.

Namespace

Drupal\Tests\image\Functional

Code

public function testEffectFormValidationErrors() {
  $account = $this
    ->drupalCreateUser([
    'administer image styles',
  ]);
  $this
    ->drupalLogin($account);

  /** @var \Drupal\image\ImageStyleInterface $style */
  $style = ImageStyle::load('thumbnail');

  // Image Scale is the only effect shipped with 'thumbnail', by default.
  $uuids = $style
    ->getEffects()
    ->getInstanceIds();
  $uuid = key($uuids);

  // We are posting the form with both, width and height, empty.
  $edit = [
    'data[width]' => '',
    'data[height]' => '',
  ];
  $path = 'admin/config/media/image-styles/manage/thumbnail/effects/' . $uuid;
  $this
    ->drupalPostForm($path, $edit, t('Update effect'));

  // Check that the error message has been displayed.
  $this
    ->assertText(t('Width and height can not both be blank.'));
}