function ImageEffectsTest::testScaleAndCropEffectWithAnchor

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

Tests the 'image_scale_and_crop' effect with an anchor.

File

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

Class

ImageEffectsTest
Tests image effects.

Namespace

Drupal\Tests\image\Kernel

Code

public function testScaleAndCropEffectWithAnchor() {
    $this->assertImageEffect([
        'scale_and_crop',
    ], 'image_scale_and_crop', [
        'anchor' => 'top-1',
        'width' => 5,
        'height' => 10,
    ]);
    // Check the parameters.
    $calls = $this->imageTestGetAllCalls();
    // X was computed and passed correctly.
    $this->assertEquals(0, $calls['scale_and_crop'][0][0]);
    // Y was computed and passed correctly.
    $this->assertEquals(1, $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]);
}

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