wiki.techinc.nl/tests/phpunit/includes/ImagePage404Test.php
Brian Wolff 3de0b70abe Make SVG files show "In other resolutions" at all sizes
Previously it only showed the sizes smaller than the nominal
size of the svg, which is silly for an infinitely scalabe
vector image.

This splits up the function a bit, in order to be able to
do unit testing.

This also changes the link below SVGs to always be
"Show original file" (show-big-image), which I think makes
more sense anyhow.

Bug: 6834
Bug: 36911
Change-Id: Ic18e555f16940c658842148c155771ef31ac5db9
2014-07-02 15:01:00 -03:00

53 lines
1.4 KiB
PHP

<?php
/**
* For doing Image Page tests that rely on 404 thumb handling
*/
class ImagePage404Test extends MediaWikiMediaTestCase {
protected function getRepoOptions() {
return parent::getRepoOptions() + array( 'transformVia404' => true );
}
function setUp() {
$this->setMwGlobals( 'wgImageLimits', array(
array( 320, 240 ),
array( 640, 480 ),
array( 800, 600 ),
array( 1024, 768 ),
array( 1280, 1024 )
) );
parent::setUp();
}
function getImagePage( $filename ) {
$title = Title::makeTitleSafe( NS_FILE, $filename );
$file = $this->dataFile( $filename );
$iPage = new ImagePage( $title );
$iPage->setFile( $file );
return $iPage;
}
/**
* @dataProvider providerGetThumbSizes
* @param $filename String
* @param $expectedNumberThumbs integer How many thumbnails to show
*/
function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
$iPage = $this->getImagePage( $filename );
$reflection = new ReflectionClass( $iPage );
$reflMethod = $reflection->getMethod( 'getThumbSizes' );
$reflMethod->setAccessible( true );
$actual = $reflMethod->invoke( $iPage, 545, 700 );
$this->assertEquals( count( $actual ), $expectedNumberThumbs );
}
function providerGetThumbSizes() {
return array(
array( 'animated.gif', 6 ),
array( 'Toll_Texas_1.svg', 6 ),
array( '80x60-Greyscale.xcf', 6 ),
array( 'jpeg-comment-binary.jpg', 6 ),
);
}
}