diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
commit | d9022f63880ce039446fba8364f68e656b7bf4cb (patch) | |
tree | 16b40fbf17bf7c9ee6f4ead25b16dd192378050a /tests/phpunit/includes/debug | |
parent | 27cf83d177256813e2e802241085fce5dd0f3fb9 (diff) |
Update to MediaWiki 1.19.0
Diffstat (limited to 'tests/phpunit/includes/debug')
-rw-r--r-- | tests/phpunit/includes/debug/MWDebugTest.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/phpunit/includes/debug/MWDebugTest.php b/tests/phpunit/includes/debug/MWDebugTest.php new file mode 100644 index 00000000..5a4e66d4 --- /dev/null +++ b/tests/phpunit/includes/debug/MWDebugTest.php @@ -0,0 +1,63 @@ +<?php + +class MWDebugTest extends MediaWikiTestCase { + + + function setUp() { + // Make sure MWDebug class is enabled + static $MWDebugEnabled = false; + if( !$MWDebugEnabled ) { + MWDebug::init(); + $MWDebugEnabled = true; + } + /** Clear log before each test */ + MWDebug::clearLog(); + } + + function testAddLog() { + MWDebug::log( 'logging a string' ); + $this->assertEquals( array( array( + 'msg' => 'logging a string', + 'type' => 'log', + 'caller' => __METHOD__ , + ) ), + MWDebug::getLog() + ); + } + + function testAddWarning() { + MWDebug::warning( 'Warning message' ); + $this->assertEquals( array( array( + 'msg' => 'Warning message', + 'type' => 'warn', + 'caller' => 'MWDebug::warning', + ) ), + MWDebug::getLog() + ); + } + + function testAvoidDuplicateDeprecations() { + MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); + MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); + + // assertCount() not available on WMF integration server + $this->assertEquals( 1, + count( MWDebug::getLog() ), + "Only one deprecated warning per function should be kept" + ); + } + + function testAvoidNonConsecutivesDuplicateDeprecations() { + MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); + MWDebug::warning( 'some warning' ); + MWDebug::log( 'we could have logged something too' ); + // Another deprecation + MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); + + // assertCount() not available on WMF integration server + $this->assertEquals( 3, + count( MWDebug::getLog() ), + "Only one deprecated warning per function should be kept" + ); + } +} |