3 use MediaWiki\MainConfigNames
;
4 use MediaWiki\Title\Title
;
7 * For doing Image Page tests that rely on 404 thumb handling
9 class ImagePage404Test
extends MediaWikiMediaTestCase
{
11 protected function getRepoOptions() {
12 return parent
::getRepoOptions() +
[ 'transformVia404' => true ];
15 protected function setUp(): void
{
16 $this->overrideConfigValue(
17 MainConfigNames
::ImageLimits
,
29 private function getImagePage( $filename ) {
30 $title = Title
::makeTitleSafe( NS_FILE
, $filename );
31 $file = $this->dataFile( $filename );
32 $iPage = new ImagePage( $title );
33 $iPage->setFile( $file );
38 * @covers \ImagePage::getThumbSizes
39 * @dataProvider providerGetThumbSizes
40 * @param string $filename
41 * @param int $expectedNumberThumbs How many thumbnails to show
43 public function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
44 $iPage = $this->getImagePage( $filename );
45 $reflection = new ReflectionClass( $iPage );
46 $reflMethod = $reflection->getMethod( 'getThumbSizes' );
47 $reflMethod->setAccessible( true );
49 $actual = $reflMethod->invoke( $iPage, 545, 700 );
50 $this->assertCount( $expectedNumberThumbs, $actual );
53 public static function providerGetThumbSizes() {
55 [ 'animated.gif', 6 ],
56 [ 'Toll_Texas_1.svg', 6 ],
57 [ '80x60-Greyscale.xcf', 6 ],
58 [ 'jpeg-comment-binary.jpg', 6 ],