test with MWDebug enabled (made possible by r109032)
[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 /**
21 * @group Broken
22 */
23 function testAddLog() {
24 MWDebug::log( 'logging a string' );
25 $this->assertEquals( array( array(
26 'msg' => 'logging a string',
27 'type' => 'log',
28 'caller' => __METHOD__ ,
29 ) ),
30 MWDebug::getLog()
31 );
32 }
33
34 /**
35 * @group Broken
36 */
37 function testAddWarning() {
38 MWDebug::warning( 'Warning message' );
39 $this->assertEquals( array( array(
40 'msg' => 'Warning message',
41 'type' => 'warn',
42 'caller' => 'MWDebug::warning',
43 ) ),
44 MWDebug::getLog()
45 );
46 }
47
48 /**
49 * Broken on gallium which use an old PHPUnit version
50 * @group Broken
51 */
52 function testAvoidDuplicateDeprecations() {
53 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
54 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
55
56 $this->assertCount( 1,
57 MWDebug::getLog(),
58 "Only one deprecated warning per function should be kept"
59 );
60 }
61
62 /**
63 * Broken on gallium which use an old PHPUnit version
64 * @group Broken
65 */
66 function testAvoidNonConsecutivesDuplicateDeprecations() {
67 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
68 MWDebug::warning( 'some warning' );
69 MWDebug::log( 'we could have logged something too' );
70 // Another deprecation
71 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
72
73 $this->assertCount( 3,
74 MWDebug::getLog(),
75 "Only one deprecated warning per function should be kept"
76 );
77 }
78 }