You are here

protected function ImageEffectsTestBase::changeToolkit in Image Effects 8.3

Same name and namespace in other branches
  1. 8 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::changeToolkit()
  2. 8.2 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::changeToolkit()

Change 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.

26 calls to ImageEffectsTestBase::changeToolkit()
AspectSwitcherTest::testAspectSwitcherEffect in tests/src/Functional/Effect/AspectSwitcherTest.php
AspectSwitcher effect test.
AutoOrientTest::testAutoOrientAllTags in tests/src/Functional/Effect/AutoOrientTest.php
Auto Orientation effect test, all EXIF orientation tags.
AutoOrientTest::testAutoOrientEffect in tests/src/Functional/Effect/AutoOrientTest.php
Auto Orientation effect test.
BackgroundTest::testBackgroundEffect in tests/src/Functional/Effect/BackgroundTest.php
Background effect test.
BrightnessTest::testBrightnessEffect in tests/src/Functional/Effect/BrightnessTest.php
Brightness effect test.

... See full list

File

tests/src/Functional/ImageEffectsTestBase.php, line 224

Class

ImageEffectsTestBase
Base test class for image_effects tests.

Namespace

Drupal\Tests\image_effects\Functional

Code

protected function changeToolkit($toolkit_id, $toolkit_config, array $toolkit_settings) {
  \Drupal::configFactory()
    ->getEditable('system.image')
    ->set('toolkit', $toolkit_id)
    ->save();
  $config = \Drupal::configFactory()
    ->getEditable($toolkit_config);
  foreach ($toolkit_settings as $setting => $value) {
    $config
      ->set($setting, $value);
  }
  $config
    ->save();

  // Bots running automated test on d.o. do not have ImageMagick or
  // GraphicsMagick binaries installed, so the test will be skipped; they can
  // be run locally if binaries are installed.
  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.");
    }
  }
  $this->container
    ->get('image.factory')
    ->setToolkitId($toolkit_id);
}