function ImageTest::testScaleDimensions

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/ImageTest.php \Drupal\Tests\Component\Utility\ImageTest::testScaleDimensions()
  2. 10 core/tests/Drupal/Tests/Component/Utility/ImageTest.php \Drupal\Tests\Component\Utility\ImageTest::testScaleDimensions()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/ImageTest.php \Drupal\Tests\Component\Utility\ImageTest::testScaleDimensions()

Tests all control flow branches in image_dimensions_scale().

@dataProvider providerTestScaleDimensions

File

core/tests/Drupal/Tests/Component/Utility/ImageTest.php, line 19

Class

ImageTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Utility%21Image.php/class/Image/9" title="Provides helpers to operate on images." class="local">\Drupal\Component\Utility\Image</a> @group Image

Namespace

Drupal\Tests\Component\Utility

Code

public function testScaleDimensions($input, $output) {
    // Process the test dataset.
    $return_value = Image::scaleDimensions($input['dimensions'], $input['width'], $input['height'], $input['upscale']);
    // Check the width.
    $this->assertEquals($output['dimensions']['width'], $input['dimensions']['width'], sprintf('Computed width (%s) does not equal expected width (%s)', $output['dimensions']['width'], $input['dimensions']['width']));
    // Check the height.
    $this->assertEquals($output['dimensions']['height'], $input['dimensions']['height'], sprintf('Computed height (%s) does not equal expected height (%s)', $output['dimensions']['height'], $input['dimensions']['height']));
    // Check the return value.
    $this->assertEquals($output['return_value'], $return_value, 'Incorrect return value.');
}

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