Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / page / ImagePage404Test.php
blob46610bb338a9fefd4d12cac0614557aa4c0b77bf
1 <?php
3 use MediaWiki\MainConfigNames;
4 use MediaWiki\Title\Title;
6 /**
7 * For doing Image Page tests that rely on 404 thumb handling
8 */
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,
19 [ 320, 240 ],
20 [ 640, 480 ],
21 [ 800, 600 ],
22 [ 1024, 768 ],
23 [ 1280, 1024 ]
26 parent::setUp();
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 );
34 return $iPage;
37 /**
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() {
54 return [
55 [ 'animated.gif', 6 ],
56 [ 'Toll_Texas_1.svg', 6 ],
57 [ '80x60-Greyscale.xcf', 6 ],
58 [ 'jpeg-comment-binary.jpg', 6 ],