You are here

public function ImageEffectsTest::testScaleAndCropEffect in Drupal 9

Tests the 'image_scale_and_crop' effect.

File

core/modules/image/tests/src/Kernel/ImageEffectsTest.php, line 123

Class

ImageEffectsTest
Tests image effects.

Namespace

Drupal\Tests\image\Kernel

Code

public function testScaleAndCropEffect() {
  $this
    ->assertImageEffect([
    'scale_and_crop',
  ], 'image_scale_and_crop', [
    'width' => 5,
    'height' => 10,
  ]);

  // Check the parameters.
  $calls = $this
    ->imageTestGetAllCalls();

  // X was computed and passed correctly.
  $this
    ->assertEquals(7.5, $calls['scale_and_crop'][0][0]);

  // Y was computed and passed correctly.
  $this
    ->assertEquals(0, $calls['scale_and_crop'][0][1]);

  // Width was computed and passed correctly.
  $this
    ->assertEquals(5, $calls['scale_and_crop'][0][2]);

  // Height was computed and passed correctly.
  $this
    ->assertEquals(10, $calls['scale_and_crop'][0][3]);
}