function ToolkitTest::testScaleAndCrop

Test the image_scale_and_crop() function.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTest.php, line 84
Definition of Drupal\system\Tests\Image\ToolkitTest.

Class

ToolkitTest
Test that the functions in image.inc correctly pass data to the toolkit.

Namespace

Drupal\system\Tests\Image

Code

function testScaleAndCrop() {
  $this
    ->assertTrue(image_scale_and_crop($this->image, 5, 10), 'Function returned the expected value.');
  $this
    ->assertToolkitOperationsCalled(array(
    'resize',
    'crop',
  ));

  // Check the parameters.
  $calls = $this
    ->imageTestGetAllCalls();
  $this
    ->assertEqual($calls['crop'][0][1], 7.5, 'X was computed and passed correctly');
  $this
    ->assertEqual($calls['crop'][0][2], 0, 'Y was computed and passed correctly');
  $this
    ->assertEqual($calls['crop'][0][3], 5, 'Width was computed and passed correctly');
  $this
    ->assertEqual($calls['crop'][0][4], 10, 'Height was computed and passed correctly');
}