Add some wfDebug() unit tests
authorX! <soxred93@users.mediawiki.org>
Sun, 2 Jan 2011 01:59:52 +0000 (01:59 +0000)
committerX! <soxred93@users.mediawiki.org>
Sun, 2 Jan 2011 01:59:52 +0000 (01:59 +0000)
tests/phpunit/includes/GlobalTest.php

index 07b076d..1e09f39 100644 (file)
@@ -464,6 +464,32 @@ class GlobalTest extends MediaWikiTestCase {
                }
                
        }
+       
+       
+       function testDebugFunctionTest() {
+               global $wgDebugLogFile;
+               
+               $old_log_file = $wgDebugLogFile;
+               
+               $wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
+               
+               
+               wfDebug( "This is a normal string" );
+               $this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) );
+               unlink( $wgDebugLogFile );
+               
+               wfDebug( "This is nöt an ASCII string" );
+               $this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) );
+               unlink( $wgDebugLogFile );
+               
+               wfDebug( "\00305This has böth UTF and control chars\003" );
+               $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
+               unlink( $wgDebugLogFile );
+               
+               
+               $wgDebugLogFile = $old_log_file;
+               
+       }
 
        /* TODO: many more! */
 }