From 14f74d141ab5580688bfd46d2f74c026e43ed967 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Apr 2015 06:11:44 +0200 Subject: Update to MediaWiki 1.24.2 --- tests/phpunit/mocks/media/MockBitmapHandler.php | 32 +++++++++ tests/phpunit/mocks/media/MockDjVuHandler.php | 49 ++++++++++++++ tests/phpunit/mocks/media/MockImageHandler.php | 86 +++++++++++++++++++++++++ tests/phpunit/mocks/media/MockSvgHandler.php | 28 ++++++++ 4 files changed, 195 insertions(+) create mode 100644 tests/phpunit/mocks/media/MockBitmapHandler.php create mode 100644 tests/phpunit/mocks/media/MockDjVuHandler.php create mode 100644 tests/phpunit/mocks/media/MockImageHandler.php create mode 100644 tests/phpunit/mocks/media/MockSvgHandler.php (limited to 'tests/phpunit/mocks/media') diff --git a/tests/phpunit/mocks/media/MockBitmapHandler.php b/tests/phpunit/mocks/media/MockBitmapHandler.php new file mode 100644 index 00000000..38cacf9f --- /dev/null +++ b/tests/phpunit/mocks/media/MockBitmapHandler.php @@ -0,0 +1,32 @@ +getClientScalingThumbnailImage( $image, $scalerParams ); + } +} diff --git a/tests/phpunit/mocks/media/MockDjVuHandler.php b/tests/phpunit/mocks/media/MockDjVuHandler.php new file mode 100644 index 00000000..31cb13dc --- /dev/null +++ b/tests/phpunit/mocks/media/MockDjVuHandler.php @@ -0,0 +1,49 @@ +normaliseParams( $image, $params ) ) { + return new TransformParameterError( $params ); + } + $width = $params['width']; + $height = $params['height']; + $page = $params['page']; + if ( $page > $this->pageCount( $image ) ) { + return new MediaTransformError( + 'thumbnail_error', + $width, + $height, + wfMessage( 'djvu_page_error' )->text() + ); + } + + $params = array( + 'width' => $width, + 'height' => $height, + 'page' => $page + ); + + return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); + } +} diff --git a/tests/phpunit/mocks/media/MockImageHandler.php b/tests/phpunit/mocks/media/MockImageHandler.php new file mode 100644 index 00000000..e0a72fd6 --- /dev/null +++ b/tests/phpunit/mocks/media/MockImageHandler.php @@ -0,0 +1,86 @@ +normaliseParams( $image, $params ); + + $scalerParams = array( + # The size to which the image will be resized + 'physicalWidth' => $params['physicalWidth'], + 'physicalHeight' => $params['physicalHeight'], + 'physicalDimensions' => "{$params['physicalWidth']}x{$params['physicalHeight']}", + # The size of the image on the page + 'clientWidth' => $params['width'], + 'clientHeight' => $params['height'], + # Comment as will be added to the EXIF of the thumbnail + 'comment' => isset( $params['descriptionUrl'] ) ? + "File source: {$params['descriptionUrl']}" : '', + # Properties of the original image + 'srcWidth' => $image->getWidth(), + 'srcHeight' => $image->getHeight(), + 'mimeType' => $image->getMimeType(), + 'dstPath' => $dstPath, + 'dstUrl' => $dstUrl, + ); + + # In some cases, we do not bother generating a thumbnail. + if ( !$image->mustRender() && + $scalerParams['physicalWidth'] == $scalerParams['srcWidth'] + && $scalerParams['physicalHeight'] == $scalerParams['srcHeight'] + ) { + wfDebug( __METHOD__ . ": returning unscaled image\n" ); + // getClientScalingThumbnailImage is protected + return $that->doClientImage( $image, $scalerParams ); + } + + return new ThumbnailImage( $image, $dstUrl, false, $params ); + } +} diff --git a/tests/phpunit/mocks/media/MockSvgHandler.php b/tests/phpunit/mocks/media/MockSvgHandler.php new file mode 100644 index 00000000..21520c44 --- /dev/null +++ b/tests/phpunit/mocks/media/MockSvgHandler.php @@ -0,0 +1,28 @@ +