Add @covers tags to page tests
[lhc/web/wiklou.git] / tests / phpunit / includes / page / ImagePage404Test.php
1 <?php
2 /**
3 * For doing Image Page tests that rely on 404 thumb handling
4 */
5 class ImagePage404Test extends MediaWikiMediaTestCase {
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
30 /**
31 * @covers ImagePage::getThumbSizes
32 * @dataProvider providerGetThumbSizes
33 * @param string $filename
34 * @param int $expectedNumberThumbs How many thumbnails to show
35 */
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
46 function providerGetThumbSizes() {
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 }