]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - t/inc/ImageFunctions.t
MediaWiki 1.14.0
[autoinstallsdev/mediawiki.git] / t / inc / ImageFunctions.t
1 #!/usr/bin/env php
2 <?php
3
4 define( 'MEDIAWIKI', true );
5 require 't/Test.php';
6
7 require 'includes/Defines.php';
8
9 $vals = array(
10         array(
11                 'width' => 50,
12                 'height' => 50,
13                 'tests' => array(
14                         50 => 50,
15                         17 => 17,
16                         18 => 18 ) ),
17         array(
18                 'width' => 366,
19                 'height' => 300,
20                 'tests' => array(
21                         50 => 61,
22                         17 => 21,
23                         18 => 22 ) ),
24         array(
25                 'width' => 300,
26                 'height' => 366,
27                 'tests' => array(
28                         50 => 41,
29                         17 => 14,
30                         18 => 15 ) ),
31         array(
32                 'width' => 100,
33                 'height' => 400,
34                 'tests' => array(
35                         50 => 12,
36                         17 => 4,
37                         18 => 4 ) )
38 );
39
40 plan( 3 + 3 * count( $vals ) );
41
42 require_ok( 'includes/ProfilerStub.php' );
43 require_ok( 'includes/GlobalFunctions.php' );
44 require_ok( 'includes/ImageFunctions.php' );
45
46 foreach( $vals as $row ) {
47         extract( $row );
48         foreach( $tests as $max => $expected ) {
49                 $y = round( $expected * $height / $width );
50                 $result = wfFitBoxWidth( $width, $height, $max );
51                 $y2 = round( $result * $height / $width );
52                 is( $result, $expected,
53                         "($width, $height, $max) wanted: {$expected}x{$y}, got: {$result}x{$y2}" );
54         }
55 }
56