Merge "Revert "Show a "(blocked)" hint on Special:ListUsers/ActiveUsers""
[lhc/web/wiklou.git] / tests / phpunit / includes / debug / MWDebugTest.php
1 <?php
2
3 class MWDebugTest extends MediaWikiTestCase {
4
5
6 protected 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 wfSuppressWarnings();
16 }
17
18 protected function tearDown() {
19 wfRestoreWarnings();
20 }
21
22 function testAddLog() {
23 MWDebug::log( 'logging a string' );
24 $this->assertEquals( array( array(
25 'msg' => 'logging a string',
26 'type' => 'log',
27 'caller' => __METHOD__ ,
28 ) ),
29 MWDebug::getLog()
30 );
31 }
32
33 function testAddWarning() {
34 MWDebug::warning( 'Warning message' );
35 $this->assertEquals( array( array(
36 'msg' => 'Warning message',
37 'type' => 'warn',
38 'caller' => 'MWDebugTest::testAddWarning',
39 ) ),
40 MWDebug::getLog()
41 );
42 }
43
44 function testAvoidDuplicateDeprecations() {
45 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
46 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
47
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"
52 );
53 }
54
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' );
61
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"
66 );
67 }
68 }