function ImageTest::testScaleDimensions

Same name 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 \Drupal\Component\Utility\Image @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.