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' );
28 'msg' => 'logging a string',
30 'caller' => __METHOD__
,
36 function testAddWarning() {
37 MWDebug
::warning( 'Warning message' );
40 'msg' => 'Warning message',
42 'caller' => 'MWDebugTest::testAddWarning',
48 function testAvoidDuplicateDeprecations() {
49 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
50 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
52 // assertCount() not available on WMF integration server
53 $this->assertEquals( 1,
54 count( MWDebug
::getLog() ),
55 "Only one deprecated warning per function should be kept"
59 function testAvoidNonConsecutivesDuplicateDeprecations() {
60 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
61 MWDebug
::warning( 'some warning' );
62 MWDebug
::log( 'we could have logged something too' );
63 // Another deprecation
64 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
66 // assertCount() not available on WMF integration server
67 $this->assertEquals( 3,
68 count( MWDebug
::getLog() ),
69 "Only one deprecated warning per function should be kept"