| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\MainConfigNames; |
| 4 |
use MediaWiki\Title\Title; |
| 5 |
use Wikimedia\TestingAccessWrapper; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class ImagePage404Test extends MediaWikiMediaTestCase { |
| 11 |
|
| 12 |
protected function getRepoOptions() { |
| 13 |
return parent::getRepoOptions() + [ 'transformVia404' => true ]; |
| 14 |
} |
| 15 |
|
| 16 |
protected function setUp(): void { |
| 17 |
$this->overrideConfigValue( |
| 18 |
MainConfigNames::ImageLimits, |
| 19 |
[ |
| 20 |
[ 320, 240 ], |
| 21 |
[ 640, 480 ], |
| 22 |
[ 800, 600 ], |
| 23 |
[ 1024, 768 ], |
| 24 |
[ 1280, 1024 ] |
| 25 |
] |
| 26 |
); |
| 27 |
parent::setUp(); |
| 28 |
} |
| 29 |
|
| 30 |
private function getImagePage( $filename ) { |
| 31 |
$title = Title::makeTitleSafe( NS_FILE, $filename ); |
| 32 |
$file = $this->dataFile( $filename ); |
| 33 |
$iPage = new ImagePage( $title ); |
| 34 |
$iPage->setFile( $file ); |
| 35 |
return $iPage; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public function testGetThumbSizes( $filename, $expectedNumberThumbs ) { |
| 45 |
|
| 46 |
$iPage = TestingAccessWrapper::newFromObject( $this->getImagePage( $filename ) ); |
| 47 |
|
| 48 |
$actual = $iPage->getThumbSizes( 545, 700 ); |
| 49 |
$this->assertCount( $expectedNumberThumbs, $actual ); |
| 50 |
} |
| 51 |
|
| 52 |
public static function providerGetThumbSizes() { |
| 53 |
return [ |
| 54 |
[ 'animated.gif', 6 ], |
| 55 |
[ 'Toll_Texas_1.svg', 6 ], |
| 56 |
[ '80x60-Greyscale.xcf', 6 ], |
| 57 |
[ 'jpeg-comment-binary.jpg', 6 ], |
| 58 |
]; |
| 59 |
} |
| 60 |
} |