3 class MWDebugTest
extends MediaWikiTestCase
{
6 protected function setUp() {
8 // Make sure MWDebug class is enabled
9 static $MWDebugEnabled = false;
10 if( !$MWDebugEnabled ) {
12 $MWDebugEnabled = true;
14 /** Clear log before each test */
19 protected function tearDown() {
24 function testAddLog() {
25 MWDebug
::log( 'logging a string' );
26 $this->assertEquals( array( array(
27 'msg' => 'logging a string',
29 'caller' => __METHOD__
,
35 function testAddWarning() {
36 MWDebug
::warning( 'Warning message' );
37 $this->assertEquals( array( array(
38 'msg' => 'Warning message',
40 'caller' => 'MWDebugTest::testAddWarning',
46 function testAvoidDuplicateDeprecations() {
47 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
48 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
50 // assertCount() not available on WMF integration server
51 $this->assertEquals( 1,
52 count( MWDebug
::getLog() ),
53 "Only one deprecated warning per function should be kept"
57 function testAvoidNonConsecutivesDuplicateDeprecations() {
58 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
59 MWDebug
::warning( 'some warning' );
60 MWDebug
::log( 'we could have logged something too' );
61 // Another deprecation
62 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
64 // assertCount() not available on WMF integration server
65 $this->assertEquals( 3,
66 count( MWDebug
::getLog() ),
67 "Only one deprecated warning per function should be kept"