6 class MediaHandlerTest
extends MediaWikiTestCase
{
9 * @covers MediaHandler::fitBoxWidth
11 * @dataProvider provideTestFitBoxWidth
13 public function testFitBoxWidth( $width, $height, $max, $expected ) {
14 $y = round( $expected * $height / $width );
15 $result = MediaHandler
::fitBoxWidth( $width, $height, $max );
16 $y2 = round( $result * $height / $width );
17 $this->assertEquals( $expected,
19 "($width, $height, $max) wanted: {$expected}x$y, got: {z$result}x$y2" );
22 public function provideTestFitBoxWidth() {
24 $this->provideTestFitBoxWidthSingle( 50, 50, array(
29 $this->provideTestFitBoxWidthSingle( 366, 300, array(
34 $this->provideTestFitBoxWidthSingle( 300, 366, array(
39 $this->provideTestFitBoxWidthSingle( 100, 400, array(
47 private function provideTestFitBoxWidthSingle( $width, $height, $tests ) {
49 foreach ( $tests as $max => $expected ) {
50 $result[] = array( $width, $height, $max, $expected );