function RectangleTest::providerPhp55RotateDimensions
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Utility/RectangleTest.php \Drupal\Tests\Component\Utility\RectangleTest::providerPhp55RotateDimensions()
- 8.9.x core/tests/Drupal/Tests/Component/Utility/RectangleTest.php \Drupal\Tests\Component\Utility\RectangleTest::providerPhp55RotateDimensions()
- 11.x core/tests/Drupal/Tests/Component/Utility/RectangleTest.php \Drupal\Tests\Component\Utility\RectangleTest::providerPhp55RotateDimensions()
Provides data for image dimension rotation tests.
This dataset sample was generated by running on PHP 5.5 the function below
- first, for all integer rotation angles (-360 to 360) on a rectangle 40x20;
- second, for 500 random float rotation angle in the range -360 to 360 on a rectangle 40x20;
- third, on 1000 rectangles of random WxH rotated to a random float angle in the range -360 to 360
- fourth, on 2000 rectangles of random WxH rotated to a random integer angle multiple of 30 degrees in the range -360 to 360 (which is the most tricky case).
Using the GD toolkit operations gives us true data coming from the GD library that can be used to match against the Rectangle class under test.
protected function rotateResults($width, $height, $angle, &$new_width, &$new_height) {
$image = \Drupal::service('image.factory')->get(NULL, 'gd');
$image->createNew($width, $height);
$old = $image->getToolkit()->getGdImage();
$image->rotate($angle);
$new_width = $image->getWidth();
$new_height = $image->getHeight();
}
Return value
array[] A simple array of simple arrays, each having the following elements:
- original image width
- original image height
- rotation angle in degrees
- expected image width after rotation
- expected image height after rotation
See also
testRotateDimensions()
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ RectangleTest.php, line 99
Class
- RectangleTest
- @coversDefaultClass \Drupal\Component\Utility\Rectangle @group Image
Namespace
Drupal\Tests\Component\UtilityCode
public static function providerPhp55RotateDimensions() {
// The dataset is stored in a .json file because it is very large and causes
// problems for PHPCS.
return json_decode(file_get_contents(__DIR__ . '/fixtures/RectangleTest.json'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.