diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-09-04 05:51:59 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-09-04 05:51:59 +0200 |
commit | 91e194556c52d2f354344f930419eef2dd6267f0 (patch) | |
tree | 0cd12490d3cd3499274017c9b799d0f738d3719e /tests/phpunit/includes/debug/MWDebugTest.php | |
parent | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (diff) |
Update to MediaWiki 1.21.2
Diffstat (limited to 'tests/phpunit/includes/debug/MWDebugTest.php')
-rw-r--r-- | tests/phpunit/includes/debug/MWDebugTest.php | 72 |
1 files changed, 72 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..9026cb90 --- /dev/null +++ b/tests/phpunit/includes/debug/MWDebugTest.php @@ -0,0 +1,72 @@ +<?php + +class MWDebugTest extends MediaWikiTestCase { + + + protected function setUp() { + parent::setUp(); + // Make sure MWDebug class is enabled + static $MWDebugEnabled = false; + if ( !$MWDebugEnabled ) { + MWDebug::init(); + $MWDebugEnabled = true; + } + /** Clear log before each test */ + MWDebug::clearLog(); + wfSuppressWarnings(); + } + + protected function tearDown() { + wfRestoreWarnings(); + parent::tearDown(); + } + + 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' => 'MWDebugTest::testAddWarning', + ) ), + 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" + ); + } +} |