summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/media/BitmapScalingTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/media/BitmapScalingTest.php')
-rw-r--r--tests/phpunit/includes/media/BitmapScalingTest.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/phpunit/includes/media/BitmapScalingTest.php b/tests/phpunit/includes/media/BitmapScalingTest.php
index 5bcd3232..11d9dc47 100644
--- a/tests/phpunit/includes/media/BitmapScalingTest.php
+++ b/tests/phpunit/includes/media/BitmapScalingTest.php
@@ -3,13 +3,16 @@
class BitmapScalingTest extends MediaWikiTestCase {
function setUp() {
- global $wgMaxImageArea;
+ global $wgMaxImageArea, $wgCustomConvertCommand;
$this->oldMaxImageArea = $wgMaxImageArea;
+ $this->oldCustomConvertCommand = $wgCustomConvertCommand;
$wgMaxImageArea = 1.25e7; // 3500x3500
+ $wgCustomConvertCommand = 'dummy'; // Set so that we don't get client side rendering
}
function tearDown() {
- global $wgMaxImageArea;
+ global $wgMaxImageArea, $wgCustomConvertCommand;
$wgMaxImageArea = $this->oldMaxImageArea;
+ $wgCustomConvertCommand = $this->oldCustomConvertCommand;
}
/**
* @dataProvider provideNormaliseParams
@@ -105,14 +108,22 @@ class BitmapScalingTest extends MediaWikiTestCase {
$file = new FakeDimensionFile( array( 4000, 4000 ) );
$handler = new BitmapHandler;
$params = array( 'width' => '3700' ); // Still bigger than max size.
- $this->assertFalse( $handler->normaliseParams( $file, $params ) );
+ $this->assertEquals( 'TransformParameterError',
+ get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
}
function testTooBigMustRenderImage() {
$file = new FakeDimensionFile( array( 4000, 4000 ) );
$file->mustRender = true;
$handler = new BitmapHandler;
$params = array( 'width' => '5000' ); // Still bigger than max size.
- $this->assertFalse( $handler->normaliseParams( $file, $params ) );
+ $this->assertEquals( 'TransformParameterError',
+ get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
+ }
+
+ function testImageArea() {
+ $file = new FakeDimensionFile( array( 7, 9 ) );
+ $handler = new BitmapHandler;
+ $this->assertEquals( 63, $handler->getImageArea( $file ) );
}
}
@@ -120,7 +131,8 @@ class FakeDimensionFile extends File {
public $mustRender = false;
public function __construct( $dimensions ) {
- parent::__construct( Title::makeTitle( NS_FILE, 'Test' ), null );
+ parent::__construct( Title::makeTitle( NS_FILE, 'Test' ),
+ new NullRepo( null ) );
$this->dimensions = $dimensions;
}
@@ -133,4 +145,7 @@ class FakeDimensionFile extends File {
public function mustRender() {
return $this->mustRender;
}
+ public function getPath() {
+ return '';
+ }
}