ToolkitSetupFormTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php
View source
<?php
namespace Drupal\system\Tests\Image;
use Drupal\simpletest\WebTestBase;
class ToolkitSetupFormTest extends WebTestBase {
protected $adminUser;
public static $modules = array(
'system',
'image_test',
);
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser(array(
'administer site configuration',
));
$this
->drupalLogin($this->adminUser);
}
function testToolkitSetupForm() {
$this
->drupalGet('admin/config/media/image-toolkit');
$this
->assertFieldByName('image_toolkit', 'gd', 'The default image toolkit is GD.');
$edit = array(
'gd[image_jpeg_quality]' => '70',
);
$this
->drupalPostForm(NULL, $edit, 'Save configuration');
$this
->assertEqual($this
->config('system.image.gd')
->get('jpeg_quality'), '70');
$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');
$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');
$this
->drupalLogin($this
->drupalCreateUser(array(
'access administration pages',
)));
$this
->drupalGet('admin/config/media/image-toolkit');
$this
->assertResponse(403);
}
}