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 */
22 function testAddLog() {
23 MWDebug
::log( 'logging a string' );
24 $this->assertEquals( array( array(
25 'msg' => 'logging a string',
27 'caller' => __METHOD__
,
33 function testAddWarning() {
34 MWDebug
::warning( 'Warning message' );
35 $this->assertEquals( array( array(
36 'msg' => 'Warning message',
38 'caller' => 'MWDebugTest::testAddWarning',
44 function testAvoidDuplicateDeprecations() {
45 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
46 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
48 // assertCount() not available on WMF integration server
49 $this->assertEquals( 1,
50 count( MWDebug
::getLog() ),
51 "Only one deprecated warning per function should be kept"
55 function testAvoidNonConsecutivesDuplicateDeprecations() {
56 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
57 MWDebug
::warning( 'some warning' );
58 MWDebug
::log( 'we could have logged something too' );
59 // Another deprecation
60 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
62 // assertCount() not available on WMF integration server
63 $this->assertEquals( 3,
64 count( MWDebug
::getLog() ),
65 "Only one deprecated warning per function should be kept"