Merge "[FileRepo] Made getDescription() respect *_deleted fields."
[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 /** Clear log before each test */
14 MWDebug::clearLog();
15 }
16
17 function testAddLog() {
18 MWDebug::log( 'logging a string' );
19 $this->assertEquals( array( array(
20 'msg' => 'logging a string',
21 'type' => 'log',
22 'caller' => __METHOD__ ,
23 ) ),
24 MWDebug::getLog()
25 );
26 }
27
28 function testAddWarning() {
29 MWDebug::warning( 'Warning message' );
30 $this->assertEquals( array( array(
31 'msg' => 'Warning message',
32 'type' => 'warn',
33 'caller' => 'MWDebugTest::testAddWarning',
34 ) ),
35 MWDebug::getLog()
36 );
37 }
38
39 function testAvoidDuplicateDeprecations() {
40 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
41 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
42
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"
47 );
48 }
49
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' );
56
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"
61 );
62 }
63 }