3 class MWDebugTest
extends MediaWikiTestCase
{
7 // Make sure MWDebug class is enabled
8 static $MWDebugEnabled = false;
9 if( !$MWDebugEnabled ) {
11 $MWDebugEnabled = true;
16 /** Clear log before each test */
20 function testAddLog() {
21 MWDebug
::log( 'logging a string' );
22 $this->assertEquals( array( array(
23 'msg' => 'logging a string',
25 'caller' => __METHOD__
,
31 function testAddWarning() {
32 MWDebug
::warning( 'Warning message' );
33 $this->assertEquals( array( array(
34 'msg' => 'Warning message',
36 'caller' => 'MWDebug::warning',
42 function testAvoidDuplicateDeprecations() {
43 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
44 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
46 // assertCount() not available on WMF integration server
47 $this->assertEquals( 1,
48 count( MWDebug
::getLog() ),
49 "Only one deprecated warning per function should be kept"
53 function testAvoidNonConsecutivesDuplicateDeprecations() {
54 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
55 MWDebug
::warning( 'some warning' );
56 MWDebug
::log( 'we could have logged something too' );
57 // Another deprecation
58 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
60 // assertCount() not available on WMF integration server
61 $this->assertEquals( 3,
62 count( MWDebug
::getLog() ),
63 "Only one deprecated warning per function should be kept"