You are here

public function InterlaceTest::testInterlaceEffect in Image Effects 8.3

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

Interlace effect test.

@dataProvider providerToolkits

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.

File

tests/src/Functional/Effect/InterlaceTest.php, line 37

Class

InterlaceTest
Interlace effect test.

Namespace

Drupal\Tests\image_effects\Functional\Effect

Code

public function testInterlaceEffect($toolkit_id, $toolkit_config, array $toolkit_settings) {
  $this
    ->changeToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
  $test_data = [
    // Test on the PNG test image.
    [
      'test_file' => $this
        ->getTestImageCopyUri('core/tests/fixtures/files/image-test.png'),
    ],
  ];

  // Add interlace effect to the test image style.
  $effect = [
    'id' => 'image_effects_interlace',
    'data' => [
      'type' => 'Plane',
    ],
  ];
  $uuid = $this
    ->addEffectToTestStyle($effect);
  foreach ($test_data as $data) {
    $original_uri = $data['test_file'];

    // Check that ::applyEffect generates interlaced PNG or GIF or
    // progressive JPEG image.
    $derivative_uri = $this->testImageStyle
      ->buildUri($original_uri);
    $this->testImageStyle
      ->createDerivative($original_uri, $derivative_uri);
    $image = $this->imageFactory
      ->get($derivative_uri, 'gd');
    $this
      ->assertTrue($this
      ->isPngInterlaced($image));
  }

  // Remove effect.
  $uuid = $this
    ->removeEffectFromTestStyle($uuid);
}