e36e42fbfa814e86e3f02a2f7ae1ecfd4e837226
[lhc/web/wiklou.git] / tests / phpunit / includes / debug / MWDebugTest.php
1 <?php
2
3 class MWDebugTest extends MediaWikiTestCase {
4
5 function tearDown() {
6 /** Clear log before each test */
7 MWDebug::clearLog();
8 }
9
10 function testAddLog() {
11 MWDebug::log( 'logging a string' );
12 $this->assertEquals( array( array(
13 'msg' => 'logging a string',
14 'type' => 'log',
15 'caller' => __METHOD__ ,
16 ) ),
17 MWDebug::getLog()
18 );
19 }
20
21 function testAddWarning() {
22 MWDebug::warning( 'Warning message' );
23 $this->assertEquals( array( array(
24 'msg' => 'Warning message',
25 'type' => 'warn',
26 'caller' => 'MWDebug::warning',
27 ) ),
28 MWDebug::getLog()
29 );
30 }
31
32 function testAvoidDuplicateDeprecations() {
33 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
34 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
35
36 $this->assertCount( 1,
37 MWDebug::getLog(),
38 "Only one deprecated warning per function should be kept"
39 );
40 }
41
42 function testAvoidNonConsecutivesDuplicateDeprecations() {
43 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
44 MWDebug::warning( 'some warning' );
45 MWDebug::log( 'we could have logged something too' );
46 // Another deprecation
47 MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
48
49 $this->assertCount( 3,
50 MWDebug::getLog(),
51 "Only one deprecated warning per function should be kept"
52 );
53 }
54 }