2014-05-22 17:44:43 +00:00
|
|
|
<?php
|
2022-08-01 19:14:41 +00:00
|
|
|
|
|
|
|
|
use MediaWiki\MainConfigNames;
|
2023-03-01 20:33:26 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2022-08-01 19:14:41 +00:00
|
|
|
|
2014-05-22 17:44:43 +00:00
|
|
|
/**
|
|
|
|
|
* For doing Image Page tests that rely on 404 thumb handling
|
|
|
|
|
*/
|
|
|
|
|
class ImagePage404Test extends MediaWikiMediaTestCase {
|
|
|
|
|
|
|
|
|
|
protected function getRepoOptions() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return parent::getRepoOptions() + [ 'transformVia404' => true ];
|
2014-05-22 17:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
protected function setUp(): void {
|
2022-08-01 19:14:41 +00:00
|
|
|
$this->overrideConfigValue(
|
|
|
|
|
MainConfigNames::ImageLimits,
|
|
|
|
|
[
|
|
|
|
|
[ 320, 240 ],
|
|
|
|
|
[ 640, 480 ],
|
|
|
|
|
[ 800, 600 ],
|
|
|
|
|
[ 1024, 768 ],
|
|
|
|
|
[ 1280, 1024 ]
|
|
|
|
|
]
|
|
|
|
|
);
|
2014-05-22 17:44:43 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 18:24:07 +00:00
|
|
|
private function getImagePage( $filename ) {
|
2014-05-22 17:44:43 +00:00
|
|
|
$title = Title::makeTitleSafe( NS_FILE, $filename );
|
|
|
|
|
$file = $this->dataFile( $filename );
|
|
|
|
|
$iPage = new ImagePage( $title );
|
|
|
|
|
$iPage->setFile( $file );
|
|
|
|
|
return $iPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-25 07:26:41 +00:00
|
|
|
* @covers ImagePage::getThumbSizes
|
2014-05-22 17:44:43 +00:00
|
|
|
* @dataProvider providerGetThumbSizes
|
2014-07-24 12:55:43 +00:00
|
|
|
* @param string $filename
|
|
|
|
|
* @param int $expectedNumberThumbs How many thumbnails to show
|
2014-05-22 17:44:43 +00:00
|
|
|
*/
|
2019-10-09 18:24:07 +00:00
|
|
|
public function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
|
2014-05-22 17:44:43 +00:00
|
|
|
$iPage = $this->getImagePage( $filename );
|
|
|
|
|
$reflection = new ReflectionClass( $iPage );
|
|
|
|
|
$reflMethod = $reflection->getMethod( 'getThumbSizes' );
|
|
|
|
|
$reflMethod->setAccessible( true );
|
|
|
|
|
|
|
|
|
|
$actual = $reflMethod->invoke( $iPage, 545, 700 );
|
2022-02-08 05:12:43 +00:00
|
|
|
$this->assertCount( $expectedNumberThumbs, $actual );
|
2014-05-22 17:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:36:19 +00:00
|
|
|
public static function providerGetThumbSizes() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ 'animated.gif', 6 ],
|
|
|
|
|
[ 'Toll_Texas_1.svg', 6 ],
|
|
|
|
|
[ '80x60-Greyscale.xcf', 6 ],
|
|
|
|
|
[ 'jpeg-comment-binary.jpg', 6 ],
|
|
|
|
|
];
|
2014-05-22 17:44:43 +00:00
|
|
|
}
|
|
|
|
|
}
|