summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/debug
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-03-28 05:41:12 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-03-28 05:41:12 +0100
commit9441dde8bfb95277df073717ed7817dced40f948 (patch)
treeba31c10147e91bda378b77c8cae90c5651af9bfe /tests/phpunit/includes/debug
parentd417de70fcf39e0a7a15ba780b597914d16ca0f7 (diff)
Update to MediaWiki 1.22.5
Diffstat (limited to 'tests/phpunit/includes/debug')
-rw-r--r--tests/phpunit/includes/debug/MWDebugTest.php72
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..6926b1c8
--- /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();
+ }
+
+ public function testAddLog() {
+ MWDebug::log( 'logging a string' );
+ $this->assertEquals(
+ array( array(
+ 'msg' => 'logging a string',
+ 'type' => 'log',
+ 'caller' => __METHOD__,
+ ) ),
+ MWDebug::getLog()
+ );
+ }
+
+ public function testAddWarning() {
+ MWDebug::warning( 'Warning message' );
+ $this->assertEquals(
+ array( array(
+ 'msg' => 'Warning message',
+ 'type' => 'warn',
+ 'caller' => 'MWDebugTest::testAddWarning',
+ ) ),
+ MWDebug::getLog()
+ );
+ }
+
+ public 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"
+ );
+ }
+
+ public 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"
+ );
+ }
+}