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