function ImageEffectsTest::testScaleAndCropEffectWithAnchor

Same name in other branches
  1. 9 core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testScaleAndCropEffectWithAnchor()
  2. 8.9.x core/modules/image/tests/src/Functional/ImageEffectsTest.php \Drupal\Tests\image\Functional\ImageEffectsTest::testScaleAndCropEffectWithAnchor()
  3. 10 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 146

Class

ImageEffectsTest
Tests image effects.

Namespace

Drupal\Tests\image\Kernel

Code

public function testScaleAndCropEffectWithAnchor() : void {
    $this->assertImageEffect([
        'scale_and_crop',
    ], 'image_scale_and_crop', [
        'anchor' => 'top-left',
        '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(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]);
}

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