Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / includes / page / ImagePageTest.php
blob2b30cfa5ebf2c537e089d93058ee09d55d7f8228
1 <?php
2 class ImagePageTest extends MediaWikiMediaTestCase {
4 function setUp() {
5 $this->setMwGlobals( 'wgImageLimits', [
6 [ 320, 240 ],
7 [ 640, 480 ],
8 [ 800, 600 ],
9 [ 1024, 768 ],
10 [ 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 [
41 [ 1024.0, 768.0, 600.0, 600.0 ],
42 [ 600.0, 600.0 ]
45 [ 1024.0, 768.0, 1600.0, 600.0 ],
46 [ 1024.0, 384.0 ]
49 [ 1024.0, 768.0, 1024.0, 768.0 ],
50 [ 1024.0, 768.0 ]
53 [ 1024.0, 768.0, 800.0, 1000.0 ],
54 [ 614.0, 768.0 ]
57 [ 1024.0, 768.0, 0, 1000 ],
58 [ 0, 0 ]
61 [ 1024.0, 768.0, 2000, 0 ],
62 [ 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 [
84 [ 'animated.gif', 2 ],
85 [ 'Toll_Texas_1.svg', 1 ],
86 [ '80x60-Greyscale.xcf', 1 ],
87 [ 'jpeg-comment-binary.jpg', 2 ],