wiki.techinc.nl/tests/phpunit/includes/page/ImagePage404Test.php
Func 7f74a2e50c Clean up tests that misused the parameters of assertSame/Equals
Expected value is the first parameter to assertSame() or assertEquals().
And turn to use assertCount() for some assertions aginst count of array.

Based on code search `assert(?:Same|Equals)\(.+,.+expected` and I look
through files roughly, so some assertions that don't contains 'expected'
are also fixed. In the meantime, some assertions that I am not clear
about are not touched.

Change-Id: I75798b60d29fd19b33f4fdf34ed3c788db420d01
2022-02-08 07:21:10 +00:00

54 lines
1.4 KiB
PHP

<?php
/**
* For doing Image Page tests that rely on 404 thumb handling
*/
class ImagePage404Test extends MediaWikiMediaTestCase {
protected function getRepoOptions() {
return parent::getRepoOptions() + [ 'transformVia404' => true ];
}
protected function setUp(): void {
$this->setMwGlobals( 'wgImageLimits', [
[ 320, 240 ],
[ 640, 480 ],
[ 800, 600 ],
[ 1024, 768 ],
[ 1280, 1024 ]
] );
parent::setUp();
}
private function getImagePage( $filename ) {
$title = Title::makeTitleSafe( NS_FILE, $filename );
$file = $this->dataFile( $filename );
$iPage = new ImagePage( $title );
$iPage->setFile( $file );
return $iPage;
}
/**
* @covers ImagePage::getThumbSizes
* @dataProvider providerGetThumbSizes
* @param string $filename
* @param int $expectedNumberThumbs How many thumbnails to show
*/
public function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
$iPage = $this->getImagePage( $filename );
$reflection = new ReflectionClass( $iPage );
$reflMethod = $reflection->getMethod( 'getThumbSizes' );
$reflMethod->setAccessible( true );
$actual = $reflMethod->invoke( $iPage, 545, 700 );
$this->assertCount( $expectedNumberThumbs, $actual );
}
public function providerGetThumbSizes() {
return [
[ 'animated.gif', 6 ],
[ 'Toll_Texas_1.svg', 6 ],
[ '80x60-Greyscale.xcf', 6 ],
[ 'jpeg-comment-binary.jpg', 6 ],
];
}
}