2 class ImagePageTest
extends MediaWikiMediaTestCase
{
5 $this->setMwGlobals( 'wgImageLimits', array(
15 function getImagePage( $filename ) {
16 $title = Title
::makeTitleSafe( NS_FILE
, $filename );
17 $file = $this->dataFile( $filename );
18 $iPage = new ImagePage( $title );
19 $iPage->setFile( $file );
24 * @dataProvider providerGetDisplayWidthHeight
25 * @param array $dim Array [maxWidth, maxHeight, width, height]
26 * @param array $expected Array [width, height] The width and height we expect to display at
28 function testGetDisplayWidthHeight( $dim, $expected ) {
29 $iPage = $this->getImagePage( 'animated.gif' );
30 $reflection = new ReflectionClass( $iPage );
31 $reflMethod = $reflection->getMethod( 'getDisplayWidthHeight' );
32 $reflMethod->setAccessible( true );
34 $actual = $reflMethod->invoke( $iPage, $dim[0], $dim[1], $dim[2], $dim[3] );
35 $this->assertEquals( $actual, $expected );
38 function providerGetDisplayWidthHeight() {
41 array( 1024.0, 768.0, 600.0, 600.0 ),
45 array( 1024.0, 768.0, 1600.0, 600.0 ),
46 array( 1024.0, 384.0 )
49 array( 1024.0, 768.0, 1024.0, 768.0 ),
50 array( 1024.0, 768.0 )
53 array( 1024.0, 768.0, 800.0, 1000.0 ),
57 array( 1024.0, 768.0, 0, 1000 ),
61 array( 1024.0, 768.0, 2000, 0 ),
68 * @dataProvider providerGetThumbSizes
69 * @param string $filename
70 * @param int $expectedNumberThumbs How many thumbnails to show
72 function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
73 $iPage = $this->getImagePage( $filename );
74 $reflection = new ReflectionClass( $iPage );
75 $reflMethod = $reflection->getMethod( 'getThumbSizes' );
76 $reflMethod->setAccessible( true );
78 $actual = $reflMethod->invoke( $iPage, 545, 700 );
79 $this->assertEquals( count( $actual ), $expectedNumberThumbs );
82 function providerGetThumbSizes() {
84 array( 'animated.gif', 2 ),
85 array( 'Toll_Texas_1.svg', 1 ),
86 array( '80x60-Greyscale.xcf', 1 ),
87 array( 'jpeg-comment-binary.jpg', 2 ),