You are here

public function ImageEffectsTest::testCropEffect in Drupal 9

Tests the 'image_crop' effect.

File

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

Class

ImageEffectsTest
Tests image effects.

Namespace

Drupal\Tests\image\Kernel

Code

public function testCropEffect() {

  // @todo Test also keyword offsets in #3040887.
  // @see https://www.drupal.org/project/drupal/issues/3040887
  $this
    ->assertImageEffect([
    'crop',
  ], 'image_crop', [
    'anchor' => 'top-1',
    'width' => 3,
    'height' => 4,
  ]);

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

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

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

  // Width was passed correctly.
  $this
    ->assertEquals(3, $calls['crop'][0][2]);

  // Height was passed correctly.
  $this
    ->assertEquals(4, $calls['crop'][0][3]);
}