Renamed group table to groups, and renamed the fields from group_xxx to gr_xxx. Added...
[lhc/web/wiklou.git] / maintenance / parserTests.php
index 9c089fb..184f876 100644 (file)
@@ -187,7 +187,7 @@ class ParserTest {
                        }
                }
                if( $total > 0 ) {
-                       $ratio = IntVal( 100.0 * $success / $total );
+                       $ratio = sprintf( "%.2f", 100 * $success / $total );
                        print $this->termColor( 1 ) . "\nPassed $success of $total tests ($ratio%) ";
                        if( $success == $total ) {
                                print $this->termColor( 32 ) . "PASSED!";
@@ -291,7 +291,6 @@ class ParserTest {
                        'wgSitename' => 'MediaWiki',
                        'wgLanguageCode' => 'en',
                        'wgContLanguageCode' => 'en',
-                       'wgUseLatin1' => false,
                        'wgDBprefix' => 'parsertest',
                        'wgDefaultUserOptions' => array(),
                        
@@ -303,6 +302,7 @@ class ParserTest {
                        'wgCapitalLinks' => true,
                        'wgDefaultUserOptions' => array(),
                        'wgNoFollowLinks' => true,
+                       'wgThumbnailScriptPath' => false,
                        );
                $this->savedGlobals = array();
                foreach( $settings as $var => $val ) {
@@ -327,7 +327,7 @@ class ParserTest {
                        'recentchanges',
                        'watchlist', 'math', 'searchindex',
                        'interwiki', 'querycache',
-                       'objectcache', 'group'
+                       'objectcache', 'groups'
                );
        }
        
@@ -405,11 +405,25 @@ class ParserTest {
                                ) );
 
                        # Hack: initialize a group
-                       $db->insert( 'group', array(
-                               'group_id' => 1,
-                               'group_name' => 'Anonymous',
-                               'group_description' => 'Anonymous users',
-                               'group_rights' => 'read' ) );
+                       $db->insert( 'groups', array(
+                               'gr_id' => 1,
+                               'gr_name' => 'Anonymous',
+                               'gr_description' => 'Anonymous users',
+                               'gr_rights' => 'read' ) );
+                       
+                       # Hack: Insert an image to work with
+                       $db->insert( 'image', array(
+                               'img_name'        => 'Foobar.jpg',
+                               'img_size'        => 12345,
+                               'img_description' => 'Some lame file',
+                               'img_user'        => 1,
+                               'img_user_text'   => 'WikiSysop',
+                               'img_timestamp'   => $db->timestamp( '20010115123500' ),
+                               'img_width'       => 1941,
+                               'img_height'      => 220,
+                               'img_bits'        => 24,
+                               'img_type'        => 2, // 2 == JPEG
+                               ) );
                        
                        $setupDB = true;
                }
@@ -422,12 +436,20 @@ class ParserTest {
         * @access private
         */
        function setupUploadDir() {
+               global $IP;
+               
                $dir = "/tmp/mwParser-" . mt_rand() . "-images";
                mkdir( $dir );
                mkdir( $dir . '/3' );
                mkdir( $dir . '/3/3a' );
+               
+               $img = "$IP/skins/monobook/headbg.jpg";
+               $h = fopen($img, 'r');
+               $c = fread($h, filesize($img));
+               fclose($h);
+               
                $f = fopen( $dir . '/3/3a/Foobar.jpg', 'wb' );
-               fwrite( $f, 'Dummy file' );
+               fwrite( $f, $c );
                fclose( $f );
                return $dir;
        }
@@ -456,7 +478,11 @@ class ParserTest {
                unlink( "$dir/3/3a/Foobar.jpg" );
                rmdir( "$dir/3/3a" );
                rmdir( "$dir/3" );
-               @rmdir( "$dir/thumb/3/39" );
+
+               @unlink( "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" );
+               @rmdir( "$dir/thumb/3/3a/Foobar.jpg" );
+               @rmdir( "$dir/thumb/3/3a" );
+               @rmdir( "$dir/thumb/3/39" ); # wtf?
                @rmdir( "$dir/thumb/3" );
                @rmdir( "$dir/thumb" );
                rmdir( "$dir" );
@@ -714,4 +740,4 @@ $ok = $tester->runTestsFromFile( 'maintenance/parserTests.txt' );
 
 exit ($ok ? 0 : -1);
 
-?>
\ No newline at end of file
+?>