Merge "Revert "Declare visibility for class properties in MySQLMasterPos""
[lhc/web/wiklou.git] / tests / phpunit / includes / media / MediaHandlerTest.php
1 <?php
2
3 class MediaHandlerTest extends MediaWikiTestCase {
4
5 /**
6 * @covers MediaHandler::fitBoxWidth
7 * @todo split into a dataprovider and test method
8 */
9 public function testFitBoxWidth() {
10 $vals = array(
11 array(
12 'width' => 50,
13 'height' => 50,
14 'tests' => array(
15 50 => 50,
16 17 => 17,
17 18 => 18 ) ),
18 array(
19 'width' => 366,
20 'height' => 300,
21 'tests' => array(
22 50 => 61,
23 17 => 21,
24 18 => 22 ) ),
25 array(
26 'width' => 300,
27 'height' => 366,
28 'tests' => array(
29 50 => 41,
30 17 => 14,
31 18 => 15 ) ),
32 array(
33 'width' => 100,
34 'height' => 400,
35 'tests' => array(
36 50 => 12,
37 17 => 4,
38 18 => 4 ) ) );
39 foreach ( $vals as $row ) {
40 $tests = $row['tests'];
41 $height = $row['height'];
42 $width = $row['width'];
43 foreach ( $tests as $max => $expected ) {
44 $y = round( $expected * $height / $width );
45 $result = MediaHandler::fitBoxWidth( $width, $height, $max );
46 $y2 = round( $result * $height / $width );
47 $this->assertEquals( $expected,
48 $result,
49 "($width, $height, $max) wanted: {$expected}x$y, got: {$result}x$y2" );
50 }
51 }
52 }
53 }