ToolkitSetupFormTest.php in Drupal 9
File
core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php
View source
<?php
namespace Drupal\FunctionalTests\Image;
use Drupal\Tests\BrowserTestBase;
class ToolkitSetupFormTest extends BrowserTestBase {
protected $adminUser;
protected static $modules = [
'system',
'image_test',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer site configuration',
]);
$this
->drupalLogin($this->adminUser);
}
public function testToolkitSetupForm() {
$this
->drupalGet('admin/config/media/image-toolkit');
$this
->assertSession()
->fieldValueEquals('image_toolkit', 'gd');
$edit = [
'gd[image_jpeg_quality]' => '70',
];
$this
->submitForm($edit, 'Save configuration');
$this
->assertEquals('70', $this
->config('system.image.gd')
->get('jpeg_quality'));
$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');
$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'));
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
]));
$this
->drupalGet('admin/config/media/image-toolkit');
$this
->assertSession()
->statusCodeEquals(403);
}
}