3 class MWDebugTest
extends MediaWikiTestCase
{
7 // Make sure MWDebug class is enabled
8 static $MWDebugEnabled = false;
9 if( !$MWDebugEnabled ) {
11 $MWDebugEnabled = true;
13 /** Clear log before each test */
17 function testAddLog() {
18 MWDebug
::log( 'logging a string' );
19 $this->assertEquals( array( array(
20 'msg' => 'logging a string',
22 'caller' => __METHOD__
,
28 function testAddWarning() {
29 MWDebug
::warning( 'Warning message' );
30 $this->assertEquals( array( array(
31 'msg' => 'Warning message',
33 'caller' => 'MWDebugTest::testAddWarning',
39 function testAvoidDuplicateDeprecations() {
40 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
41 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
43 // assertCount() not available on WMF integration server
44 $this->assertEquals( 1,
45 count( MWDebug
::getLog() ),
46 "Only one deprecated warning per function should be kept"
50 function testAvoidNonConsecutivesDuplicateDeprecations() {
51 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
52 MWDebug
::warning( 'some warning' );
53 MWDebug
::log( 'we could have logged something too' );
54 // Another deprecation
55 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
57 // assertCount() not available on WMF integration server
58 $this->assertEquals( 3,
59 count( MWDebug
::getLog() ),
60 "Only one deprecated warning per function should be kept"