MediaWiki
REL1_20
|
00001 <?php 00002 00003 class MWDebugTest extends MediaWikiTestCase { 00004 00005 00006 function setUp() { 00007 // Make sure MWDebug class is enabled 00008 static $MWDebugEnabled = false; 00009 if( !$MWDebugEnabled ) { 00010 MWDebug::init(); 00011 $MWDebugEnabled = true; 00012 } 00014 MWDebug::clearLog(); 00015 wfSuppressWarnings(); 00016 } 00017 00018 function tearDown() { 00019 wfRestoreWarnings(); 00020 } 00021 00022 function testAddLog() { 00023 MWDebug::log( 'logging a string' ); 00024 $this->assertEquals( array( array( 00025 'msg' => 'logging a string', 00026 'type' => 'log', 00027 'caller' => __METHOD__ , 00028 ) ), 00029 MWDebug::getLog() 00030 ); 00031 } 00032 00033 function testAddWarning() { 00034 MWDebug::warning( 'Warning message' ); 00035 $this->assertEquals( array( array( 00036 'msg' => 'Warning message', 00037 'type' => 'warn', 00038 'caller' => 'MWDebugTest::testAddWarning', 00039 ) ), 00040 MWDebug::getLog() 00041 ); 00042 } 00043 00044 function testAvoidDuplicateDeprecations() { 00045 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); 00046 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); 00047 00048 // assertCount() not available on WMF integration server 00049 $this->assertEquals( 1, 00050 count( MWDebug::getLog() ), 00051 "Only one deprecated warning per function should be kept" 00052 ); 00053 } 00054 00055 function testAvoidNonConsecutivesDuplicateDeprecations() { 00056 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); 00057 MWDebug::warning( 'some warning' ); 00058 MWDebug::log( 'we could have logged something too' ); 00059 // Another deprecation 00060 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); 00061 00062 // assertCount() not available on WMF integration server 00063 $this->assertEquals( 3, 00064 count( MWDebug::getLog() ), 00065 "Only one deprecated warning per function should be kept" 00066 ); 00067 } 00068 }