X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FTests%2FImage%2FToolkitSetupFormTest.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FTests%2FImage%2FToolkitSetupFormTest.php;h=7dc9d33874a1cc70b9a446bd14b681254e3e9357;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php b/web/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php new file mode 100644 index 000000000..7dc9d3387 --- /dev/null +++ b/web/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php @@ -0,0 +1,74 @@ +adminUser = $this->drupalCreateUser([ + 'administer site configuration', + ]); + $this->drupalLogin($this->adminUser); + } + + /** + * Test Image toolkit setup form. + */ + public 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 = ['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 = ['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 = ['test[test_parameter]' => '0']; + $this->drupalPostForm(NULL, $edit, 'Save configuration'); + $this->assertText(t('Test parameter should be different from 0.'), 'Validation error displayed.'); + $edit = ['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(['access administration pages'])); + $this->drupalGet('admin/config/media/image-toolkit'); + $this->assertResponse(403); + } + +}