You are here

function ToolkitSetupFormTest::testToolkitSetupForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php \Drupal\system\Tests\Image\ToolkitSetupFormTest::testToolkitSetupForm()

Test Image toolkit setup form.

File

core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php, line 47
Contains \Drupal\system\Tests\Image\ToolkitSetupFormTest.

Class

ToolkitSetupFormTest
Tests image toolkit setup form.

Namespace

Drupal\system\Tests\Image

Code

function testToolkitSetupForm() {

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

  // Test that default toolkit is GD.
  $this
    ->assertFieldByName('image_toolkit', 'gd', 'The default image toolkit is GD.');

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

  // Test changing the toolkit.
  $edit = array(
    'image_toolkit' => 'test',
  );
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
  $this
    ->assertEqual($this
    ->config('system.image')
    ->get('toolkit'), 'test');
  $this
    ->assertFieldByName('test[test_parameter]', '10');

  // Test changing the test toolkit parameter.
  $edit = array(
    'test[test_parameter]' => '0',
  );
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
  $this
    ->assertText(t('Test parameter should be different from 0.'), 'Validation error displayed.');
  $edit = array(
    'test[test_parameter]' => '20',
  );
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
  $this
    ->assertEqual($this
    ->config('system.image.test_toolkit')
    ->get('test_parameter'), '20');

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