Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / page / ImagePageTest.php
blob3c255b5f669a3a825193bc3329fd8733cd64884f
1 <?php
2 class ImagePageTest extends MediaWikiMediaTestCase {
4 function setUp() {
5 $this->setMwGlobals( 'wgImageLimits', array(
6 array( 320, 240 ),
7 array( 640, 480 ),
8 array( 800, 600 ),
9 array( 1024, 768 ),
10 array( 1280, 1024 )
11 ) );
12 parent::setUp();
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 );
20 return $iPage;
23 /**
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() {
39 return array(
40 array(
41 array( 1024.0, 768.0, 600.0, 600.0 ),
42 array( 600.0, 600.0 )
44 array(
45 array( 1024.0, 768.0, 1600.0, 600.0 ),
46 array( 1024.0, 384.0 )
48 array(
49 array( 1024.0, 768.0, 1024.0, 768.0 ),
50 array( 1024.0, 768.0 )
52 array(
53 array( 1024.0, 768.0, 800.0, 1000.0 ),
54 array( 614.0, 768.0 )
56 array(
57 array( 1024.0, 768.0, 0, 1000 ),
58 array( 0, 0 )
60 array(
61 array( 1024.0, 768.0, 2000, 0 ),
62 array( 0, 0 )
67 /**
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() {
83 return array(
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 ),