function ImageEffectsTest::testCropEffect

Same name and namespace in other branches
  1. 9 core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testCropEffect()
  2. 8.9.x core/modules/image/tests/src/Functional/ImageEffectsTest.php \Drupal\Tests\image\Functional\ImageEffectsTest::testCropEffect()
  3. 11.x core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testCropEffect()

Tests the 'image_crop' effect.

File

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

Class

ImageEffectsTest
Tests image effects.

Namespace

Drupal\Tests\image\Kernel

Code

public function testCropEffect() : void {
  // @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]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.