(bug 5378) General logs link in Special:Contributions
[lhc/web/wiklou.git] / tests / ImageTest.php
1 <?php
2
3 require_once( 'PHPUnit.php' );
4 require_once( '../includes/Defines.php' );
5 require_once( '../includes/Profiling.php' );
6 require_once( '../includes/GlobalFunctions.php' );
7 require_once( '../includes/Image.php' );
8
9 class ImageTest extends PHPUnit_TestCase {
10 function ImageTest( $name ) {
11 $this->PHPUnit_TestCase( $name );
12 }
13
14 function setUp() {
15 }
16
17 function tearDown() {
18 }
19
20 function testFitBoxWidth() {
21 $vals = array(
22 array(
23 'width' => 50,
24 'height' => 50,
25 'tests' => array(
26 50 => 50,
27 17 => 17,
28 18 => 18 ) ),
29 array(
30 'width' => 366,
31 'height' => 300,
32 'tests' => array(
33 50 => 61,
34 17 => 21,
35 18 => 22 ) ),
36 array(
37 'width' => 300,
38 'height' => 366,
39 'tests' => array(
40 50 => 41,
41 17 => 14,
42 18 => 15 ) ),
43 array(
44 'width' => 100,
45 'height' => 400,
46 'tests' => array(
47 50 => 12,
48 17 => 4,
49 18 => 4 ) ) );
50 foreach( $vals as $row ) {
51 extract( $row );
52 foreach( $tests as $max => $expected ) {
53 $y = round( $expected * $height / $width );
54 $result = wfFitBoxWidth( $width, $height, $max );
55 $y2 = round( $result * $height / $width );
56 $this->assertEquals( $expected,
57 $result,
58 "($width, $height, $max) wanted: {$expected}x$y, got: {$result}x$y2" );
59 }
60 }
61 }
62
63 /* TODO: many more! */
64 }
65
66 ?>