3 namespace Drupal\system\Tests\Image;
5 use Drupal\simpletest\WebTestBase;
8 * Tests image toolkit setup form.
12 class ToolkitSetupFormTest extends WebTestBase {
17 * @var \Drupal\user\Entity\User
26 public static $modules = ['system', 'image_test'];
31 protected function setUp() {
33 $this->adminUser = $this->drupalCreateUser([
34 'administer site configuration',
36 $this->drupalLogin($this->adminUser);
40 * Test Image toolkit setup form.
42 public function testToolkitSetupForm() {
44 $this->drupalGet('admin/config/media/image-toolkit');
46 // Test that default toolkit is GD.
47 $this->assertFieldByName('image_toolkit', 'gd', 'The default image toolkit is GD.');
49 // Test changing the jpeg image quality.
50 $edit = ['gd[image_jpeg_quality]' => '70'];
51 $this->drupalPostForm(NULL, $edit, 'Save configuration');
52 $this->assertEqual($this->config('system.image.gd')->get('jpeg_quality'), '70');
54 // Test changing the toolkit.
55 $edit = ['image_toolkit' => 'test'];
56 $this->drupalPostForm(NULL, $edit, 'Save configuration');
57 $this->assertEqual($this->config('system.image')->get('toolkit'), 'test');
58 $this->assertFieldByName('test[test_parameter]', '10');
60 // Test changing the test toolkit parameter.
61 $edit = ['test[test_parameter]' => '0'];
62 $this->drupalPostForm(NULL, $edit, 'Save configuration');
63 $this->assertText(t('Test parameter should be different from 0.'), 'Validation error displayed.');
64 $edit = ['test[test_parameter]' => '20'];
65 $this->drupalPostForm(NULL, $edit, 'Save configuration');
66 $this->assertEqual($this->config('system.image.test_toolkit')->get('test_parameter'), '20');
68 // Test access without the permission 'administer site configuration'.
69 $this->drupalLogin($this->drupalCreateUser(['access administration pages']));
70 $this->drupalGet('admin/config/media/image-toolkit');
71 $this->assertResponse(403);