protected function ToolkitSetupTrait::setUpToolkit in ImageMagick 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/ToolkitSetupTrait.php \Drupal\Tests\imagemagick\Kernel\ToolkitSetupTrait::setUpToolkit()
Sets up the image toolkit.
Parameters
string $toolkit_id: The id of the toolkit to set up.
string $toolkit_config: The config object of the toolkit to set up.
array $toolkit_settings: The settings of the toolkit to set up.
10 calls to ToolkitSetupTrait::setUpToolkit()
- EventSubscriberTest::testEventSubscriber in tests/
src/ Functional/ EventSubscriberTest.php - Test module's event subscriber.
- ToolkitImagemagickFileMetadataTest::testFileMetadata in tests/
src/ Functional/ ToolkitImagemagickFileMetadataTest.php - Test image toolkit integration with file metadata manager.
- ToolkitImagemagickFileMetadataTest::testSourceLocalPath in tests/
src/ Functional/ ToolkitImagemagickFileMetadataTest.php - Tests getSourceLocalPath() for re-creating local path.
- ToolkitImagemagickTest::testArgumentsLegacy in tests/
src/ Functional/ ToolkitImagemagickTest.php - Test legacy arguments handling.
- ToolkitImagemagickTest::testManipulations in tests/
src/ Functional/ ToolkitImagemagickTest.php - Test image toolkit operations.
File
- tests/
src/ Kernel/ ToolkitSetupTrait.php, line 47
Class
- ToolkitSetupTrait
- Trait to manage toolkit setup tasks common across tests.
Namespace
Drupal\Tests\imagemagick\KernelCode
protected function setUpToolkit($toolkit_id, $toolkit_config, array $toolkit_settings) {
if ($this instanceof KernelTestBase) {
$this
->installConfig([
'system',
'imagemagick',
]);
}
// Change the toolkit.
\Drupal::configFactory()
->getEditable('system.image')
->set('toolkit', $toolkit_id)
->save();
// Configure the toolkit.
$config = \Drupal::configFactory()
->getEditable($toolkit_config);
foreach ($toolkit_settings as $setting => $value) {
$config
->set($setting, $value);
}
$config
->save();
// Check that ImageMagick or GraphicsMagick binaries are installed, and
// mark the test skipped if not.
if ($toolkit_id === 'imagemagick') {
$status = \Drupal::service('image.toolkit.manager')
->createInstance('imagemagick')
->getExecManager()
->checkPath('');
if (!empty($status['errors'])) {
$this
->markTestSkipped("Tests for '{$toolkit_settings['binaries']}' cannot run because the binaries are not available on the shell path.");
}
}
// Set the toolkit on the image factory.
$this->imageFactory = \Drupal::service('image.factory');
$this->imageFactory
->setToolkitId($toolkit_id);
}