public function ToolkitImagemagickTest::testFormAndSettings in ImageMagick 8
Test ImageMagick subform and settings.
File
- tests/
src/ Functional/ ToolkitImagemagickTest.php, line 592
Class
- ToolkitImagemagickTest
- Tests that core image manipulations work properly through Imagemagick.
Namespace
Drupal\Tests\imagemagick\FunctionalCode
public function testFormAndSettings() {
// Change the toolkit.
\Drupal::configFactory()
->getEditable('system.image')
->set('toolkit', 'imagemagick')
->save();
// Test form is accepting wrong binaries path while setting toolkit to GD.
$this
->drupalGet('admin/config/media/image-toolkit');
$this
->assertFieldByName('image_toolkit', 'imagemagick');
$edit = [
'image_toolkit' => 'gd',
'imagemagick[suite][path_to_binaries]' => '/foo/bar',
];
$this
->drupalPostForm(NULL, $edit, 'Save configuration');
$this
->assertFieldByName('image_toolkit', 'gd');
// Change the toolkit.
\Drupal::configFactory()
->getEditable('system.image')
->set('toolkit', 'imagemagick')
->save();
$this->imageFactory
->setToolkitId('imagemagick');
$this
->assertEqual('imagemagick', $this->imageFactory
->getToolkitId());
// Test default supported image extensions.
$this
->assertEqual('gif jpe jpeg jpg png', implode(' ', $this->imageFactory
->getSupportedExtensions()));
$config = \Drupal::configFactory()
->getEditable('imagemagick.settings');
// Enable TIFF.
$image_formats = $config
->get('image_formats');
$image_formats['TIFF']['enabled'] = TRUE;
$config
->set('image_formats', $image_formats)
->save();
$this
->assertEqual('gif jpe jpeg jpg png tif tiff', implode(' ', $this->imageFactory
->getSupportedExtensions()));
// Disable PNG.
$image_formats['PNG']['enabled'] = FALSE;
$config
->set('image_formats', $image_formats)
->save();
$this
->assertEqual('gif jpe jpeg jpg tif tiff', implode(' ', $this->imageFactory
->getSupportedExtensions()));
// Disable some extensions.
$image_formats['TIFF']['exclude_extensions'] = 'tif, gif';
$config
->set('image_formats', $image_formats)
->save();
$this
->assertEqual('gif jpe jpeg jpg tiff', implode(' ', $this->imageFactory
->getSupportedExtensions()));
$image_formats['JPEG']['exclude_extensions'] = 'jpe, jpg';
$config
->set('image_formats', $image_formats)
->save();
$this
->assertEqual('gif jpeg tiff', implode(' ', $this->imageFactory
->getSupportedExtensions()));
}