MediaWiki
REL1_24
|
00001 <?php 00002 class ImagePageTest extends MediaWikiMediaTestCase { 00003 00004 function setUp() { 00005 $this->setMwGlobals( 'wgImageLimits', array( 00006 array( 320, 240 ), 00007 array( 640, 480 ), 00008 array( 800, 600 ), 00009 array( 1024, 768 ), 00010 array( 1280, 1024 ) 00011 ) ); 00012 parent::setUp(); 00013 } 00014 00015 function getImagePage( $filename ) { 00016 $title = Title::makeTitleSafe( NS_FILE, $filename ); 00017 $file = $this->dataFile( $filename ); 00018 $iPage = new ImagePage( $title ); 00019 $iPage->setFile( $file ); 00020 return $iPage; 00021 } 00022 00028 function testGetDisplayWidthHeight( $dim, $expected ) { 00029 $iPage = $this->getImagePage( 'animated.gif' ); 00030 $reflection = new ReflectionClass( $iPage ); 00031 $reflMethod = $reflection->getMethod( 'getDisplayWidthHeight' ); 00032 $reflMethod->setAccessible( true ); 00033 00034 $actual = $reflMethod->invoke( $iPage, $dim[0], $dim[1], $dim[2], $dim[3] ); 00035 $this->assertEquals( $actual, $expected ); 00036 } 00037 00038 function providerGetDisplayWidthHeight() { 00039 return array( 00040 array( 00041 array( 1024.0, 768.0, 600.0, 600.0 ), 00042 array( 600.0, 600.0 ) 00043 ), 00044 array( 00045 array( 1024.0, 768.0, 1600.0, 600.0 ), 00046 array( 1024.0, 384.0 ) 00047 ), 00048 array( 00049 array( 1024.0, 768.0, 1024.0, 768.0 ), 00050 array( 1024.0, 768.0 ) 00051 ), 00052 array( 00053 array( 1024.0, 768.0, 800.0, 1000.0 ), 00054 array( 614.0, 768.0 ) 00055 ), 00056 array( 00057 array( 1024.0, 768.0, 0, 1000 ), 00058 array( 0, 0 ) 00059 ), 00060 array( 00061 array( 1024.0, 768.0, 2000, 0 ), 00062 array( 0, 0 ) 00063 ), 00064 ); 00065 } 00066 00072 function testGetThumbSizes( $filename, $expectedNumberThumbs ) { 00073 $iPage = $this->getImagePage( $filename ); 00074 $reflection = new ReflectionClass( $iPage ); 00075 $reflMethod = $reflection->getMethod( 'getThumbSizes' ); 00076 $reflMethod->setAccessible( true ); 00077 00078 $actual = $reflMethod->invoke( $iPage, 545, 700 ); 00079 $this->assertEquals( count( $actual ), $expectedNumberThumbs ); 00080 } 00081 00082 function providerGetThumbSizes() { 00083 return array( 00084 array( 'animated.gif', 2 ), 00085 array( 'Toll_Texas_1.svg', 1 ), 00086 array( '80x60-Greyscale.xcf', 1 ), 00087 array( 'jpeg-comment-binary.jpg', 2 ), 00088 ); 00089 } 00090 }