Backup of db before drupal security update
[yaffs-website] / web / core / tests / Drupal / FunctionalTests / Image / ToolkitSetupFormTest.php
1 <?php
2
3 namespace Drupal\FunctionalTests\Image;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests image toolkit setup form.
9  *
10  * @group Image
11  */
12 class ToolkitSetupFormTest extends BrowserTestBase {
13
14   /**
15    * Admin user account.
16    *
17    * @var \Drupal\user\Entity\User
18    */
19   protected $adminUser;
20
21   /**
22    * Modules to enable.
23    *
24    * @var array
25    */
26   public static $modules = ['system', 'image_test'];
27
28   /**
29    * {@inheritdoc}
30    */
31   protected function setUp() {
32     parent::setUp();
33     $this->adminUser = $this->drupalCreateUser([
34       'administer site configuration',
35     ]);
36     $this->drupalLogin($this->adminUser);
37   }
38
39   /**
40    * Test Image toolkit setup form.
41    */
42   public function testToolkitSetupForm() {
43     // Get form.
44     $this->drupalGet('admin/config/media/image-toolkit');
45
46     // Test that default toolkit is GD.
47     $this->assertFieldByName('image_toolkit', 'gd', 'The default image toolkit is GD.');
48
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');
53
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');
59
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');
67
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);
72   }
73
74 }