enable MWDebug tests
[lhc/web/wiklou.git] / tests / phpunit / includes / debug / MWDebugTest.php
1 <?php
2
3 class MWDebugTest extends MediaWikiTestCase {
4
5
6 function setUp() {
7 // Make sure MWDebug class is enabled
8 static $MWDebugEnabled = false;
9 if( !$MWDebugEnabled ) {
10 MWDebug::init();
11 $MWDebugEnabled = true;
12 }
13 }
14
15 function tearDown() {
16 /** Clear log before each test */
17 MWDebug::clearLog();
18 }
19
20 function testAddLog() {
21 MWDebug::log( 'logging a string' );
22 $this->assertEquals( array( array(
23 'msg' => 'logging a string',
24 'type' => 'log',
25 'caller' => __METHOD__ ,
26 ) ),
27 MWDebug::getLog()
28 );
29 }
30
31 function testAddWarning() {
32 MWDebug::warning( 'Warning message' );
33 $this->assertEquals( array( array(
34 'msg' => 'Warning message',
35 'type' => 'warn',
36 'caller' => 'MWDebug::warning',
37 ) ),
38 MWDebug::getLog()
39 );
40 }
41
42 function testAvoidDuplicateDeprecations() {
43 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
44 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
45
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"
50 );
51 }
52
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' );
59
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"
64 );
65 }
66 }