MediaWiki REL1_32
ImagePage404Test.php
Go to the documentation of this file.
1<?php
6
7 protected function getRepoOptions() {
8 return parent::getRepoOptions() + [ 'transformVia404' => true ];
9 }
10
11 function setUp() {
12 $this->setMwGlobals( 'wgImageLimits', [
13 [ 320, 240 ],
14 [ 640, 480 ],
15 [ 800, 600 ],
16 [ 1024, 768 ],
17 [ 1280, 1024 ]
18 ] );
19 parent::setUp();
20 }
21
22 function getImagePage( $filename ) {
23 $title = Title::makeTitleSafe( NS_FILE, $filename );
24 $file = $this->dataFile( $filename );
25 $iPage = new ImagePage( $title );
26 $iPage->setFile( $file );
27 return $iPage;
28 }
29
36 function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
37 $iPage = $this->getImagePage( $filename );
38 $reflection = new ReflectionClass( $iPage );
39 $reflMethod = $reflection->getMethod( 'getThumbSizes' );
40 $reflMethod->setAccessible( true );
41
42 $actual = $reflMethod->invoke( $iPage, 545, 700 );
43 $this->assertEquals( count( $actual ), $expectedNumberThumbs );
44 }
45
47 return [
48 [ 'animated.gif', 6 ],
49 [ 'Toll_Texas_1.svg', 6 ],
50 [ '80x60-Greyscale.xcf', 6 ],
51 [ 'jpeg-comment-binary.jpg', 6 ],
52 ];
53 }
54}
For doing Image Page tests that rely on 404 thumb handling.
getImagePage( $filename)
testGetThumbSizes( $filename, $expectedNumberThumbs)
ImagePage::getThumbSizes providerGetThumbSizes.
Class for viewing MediaWiki file description pages.
Definition ImagePage.php:30
Specificly for testing Media handlers.
dataFile( $name, $type=null)
Utility function: Get a new file object for a file on disk but not actually in db.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2055
const NS_FILE
Definition Defines.php:70