function ImageEffectsTest::testEffectFormValidationErrors

Same name and namespace in other branches
  1. 9 core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testEffectFormValidationErrors()
  2. 10 core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testEffectFormValidationErrors()
  3. 11.x core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testEffectFormValidationErrors()

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.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.