From ca08eb6d170d375ef4fca53604956f3474c7db19 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 22 Aug 2010 22:37:30 +0000 Subject: Merged r6701:6756 from 1.7 branch into trunk git-svn-id: http://code.elgg.org/elgg/trunk@6849 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/tests/regression/trac_bugs.php | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'engine/tests/regression') diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 01900b849..5765c9c3d 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -63,4 +63,55 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { // clean up $this->entity->delete(); } + + /** + * #2063 - get_resized_image_from_existing_file() fails asked for image larger than selection and not scaling an image up + * Test get_image_resize_parameters(). + */ + public function testElggResizeImage() { + $orig_width = 100; + $orig_height = 150; + + // test against selection > max + $options = array( + 'maxwidth' => 50, + 'maxheight' => 50, + 'square' => TRUE, + 'upscale' => FALSE, + + 'x1' => 25, + 'y1' => 75, + 'x2' => 100, + 'y2' => 150 + ); + + // should get back the same x/y offset == x1, y1 and an image of 50x50 + $params = get_image_resize_parameters($orig_width, $orig_height, $options); + + $this->assertEqual($params['newwidth'], $options['maxwidth']); + $this->assertEqual($params['newheight'], $options['maxheight']); + $this->assertEqual($params['xoffset'], $options['x1']); + $this->assertEqual($params['yoffset'], $options['y1']); + + // test against selection < max + $options = array( + 'maxwidth' => 50, + 'maxheight' => 50, + 'square' => TRUE, + 'upscale' => FALSE, + + 'x1' => 75, + 'y1' => 125, + 'x2' => 100, + 'y2' => 150 + ); + + // should get back the same x/y offset == x1, y1 and an image of 50x50 + $params = get_image_resize_parameters($orig_width, $orig_height, $options); + + $this->assertEqual($params['newwidth'], $options['maxwidth']); + $this->assertEqual($params['newheight'], $options['maxheight']); + $this->assertEqual($params['xoffset'], $options['x1']); + $this->assertEqual($params['yoffset'], $options['y1']); + } } -- cgit v1.2.3