You are here

public function ToolkitSetupFormTest::testToolkitSetupForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php \Drupal\FunctionalTests\Image\ToolkitSetupFormTest::testToolkitSetupForm()
  2. 9 core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php \Drupal\FunctionalTests\Image\ToolkitSetupFormTest::testToolkitSetupForm()

Tests Image toolkit setup form.

File

core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php, line 47

Class

ToolkitSetupFormTest
Tests image toolkit setup form.

Namespace

Drupal\FunctionalTests\Image

Code

public function testToolkitSetupForm() {

  // Get form.
  $this
    ->drupalGet('admin/config/media/image-toolkit');

  // Test that default toolkit is GD.
  $this
    ->assertSession()
    ->fieldValueEquals('image_toolkit', 'gd');

  // Test changing the jpeg image quality.
  $edit = [
    'gd[image_jpeg_quality]' => '70',
  ];
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->assertEquals('70', $this
    ->config('system.image.gd')
    ->get('jpeg_quality'));

  // Test changing the toolkit.
  $edit = [
    'image_toolkit' => 'test',
  ];
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->assertEquals('test', $this
    ->config('system.image')
    ->get('toolkit'));
  $this
    ->assertSession()
    ->fieldValueEquals('test[test_parameter]', '10');

  // Test changing the test toolkit parameter.
  $edit = [
    'test[test_parameter]' => '0',
  ];
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('Test parameter should be different from 0.');
  $edit = [
    'test[test_parameter]' => '20',
  ];
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->assertEquals('20', $this
    ->config('system.image.test_toolkit')
    ->get('test_parameter'));

  // Test access without the permission 'administer site configuration'.
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'access administration pages',
  ]));
  $this
    ->drupalGet('admin/config/media/image-toolkit');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
}